If you set the text as the first index then you could just use the sort action.
As is the first value is a number so it would be sorted like this:
1,5,Grape
3,6,Grape
3,5,Pineapple
5,7,Apple
10,4,Grape
but if you set the array up like this:
grape,1,5
grape,10,4
grape,3,6
apple,5,7
pineapple,3,5
then sort would do make it like this:
apple,5,7
grape,1,5
grape,10,4
grape,3,6
pineapple,3,5
Besides that you could implement your own sorting. "bubble sort" is probably the simplest to do just look at wikipedia for some psuedo code. But it's probably easier to just rearrange your data and use the sorting action.