Sorting Tables - One method
I have to do quite a lot of stuff involving sorting tables, so I'm always on the lookout for new, faster ways of doing it. I've experimented a lot with bubble sorts in the past, as they're straightforward and easy to implememt in GameSalad, but the results have always been... meh. I could make them reasonably fast, but they'd become increasingly unresponsive the more data they were asked to sort, and if they were sorting tables with lots of columns, they'd get slower still. I tested methods posted by various users of the forums and none really offered the speed or responsiveness I needed.
In the end I abandoned the idea of bubble sorts, or sorting in ways that work well in other "programming languages" and decided to focus more on making use of the things GameSalad does well, rather than trying to shoehorn other methods in. I ended up with a method considerably faster than any I'd made before, or seen posted on the forums. I'm sure it's still nowhere near optimal, but I thought I'd share it anyway. The two key benefits of this method over others I've seen are that it will sort tables with lots of columns quite happily (my old method struggled with over 20 columns) and it gives a progress information (ish - it shows what % it has sorted but the time each % takes decreases each pass of the table).
It will sort the 23 column, 200 row demo table in under 5 seconds (on my computer and iPad, anyway). If you have a faster method, please let me know! Bumping up the loops per frame will speed things up further, but will depend on the device handling it.
I use this method to sort around ten thousand table rows, with ~50 columns, and it handles it like a champ.
Anyhow, hope this helps someone.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Comments
Very cool! Love this!
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
Thanks @Armelline
Very Generous of you!
Thanks a lot man.
@Armelline This is very exciting! How can I get hold of a copy of this example? Many thanks
Hey @NBW. It was attached to the post but with the recent forum move attachments seem to be (hopefully temporarily) missing. I'm pretty sure this was the right file.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Awesome. Checking out now. Love some Table work magic!
GSLearn.com | Templates | Free Demos | Udemy Course
Great!! This is a big help to ranking system. Thank you.
For reference, it took 0.617 sec on 30 rows.
Hi @Armelline - very elegant - works perfectly. This will be a huge help in my apps. Thanks again.
Thanks @Armelline
I have not yet come across the need to order a table, not at least that big! :)
"I use this method to sort around ten thousand table rows, with ~50 columns, and it handles it like a champ."
I'm dying of curiosity in which you walk! Hahaha
@CasualEvolution - Something for a client, so don't want to go into lots of details, but essentially it's a history of games played. That's as big as we let the tables get before resetting them and only one had got that big, though! I didn't even realise any had got that big until the sorting became unreliable, which is what prompted me to try to find a better way!
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support