I'm trying to learn how to sort my array values that contains a specific text
I just want to be able to pick a text, and move them to the top of my list.
I don't want ascending/descending orders of numbers, I just want to isolate a category if that makes sense!
I could be wrong - but I'm pretty sure the in-built sort feature includes alphabetical as well as numerical searching. You'd have to move the text over to be the first index on the X axis, but then the in-built sort function should work fine.
EDIT: Sorry - just re-read your post. To move a group to the top of the list, simple iterate through the array checking for the identifier you're looking for. When you find that identifier, push a new value to the front of the array containing the values from that index - then delete the original index.
If you want everything grouped beforehand, you'll need a place to store a list of all of the text values stored in the third column, then perform the above process for each item on that list.
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:
but if you set the array up like this:
then sort would do make it like this:
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.
Develop games in your browser. Powerful, performant & highly capable.
I ended up going with R0J0hound's method, thank you so much! that worked for me =)
yeah, its weird...i cant seem to sort from the 3rd value =/ does it only work on the first?
Yeah, only the first value is used for sorting.