Game Development Community

Array Sorting

by William Hilke · in Torque Game Builder · 06/20/2006 (9:12 pm) · 5 replies

Anyone know if there is a built in script soluition to sorting an array of numbers/items? SimSet or a space seperated list.

#1
06/21/2006 (6:21 am)
Nope.
#2
06/21/2006 (7:12 am)
You can't rely on SimSets to maintain a specific order, even if there was a way to sort their contents. TorqueScript lacks quite a few fundamental features that would make developing not only quicker but also less painful.

The best way to do it is to create your own array class in script, or find a resource that will give you the functionality you want.
#3
06/21/2006 (7:52 am)
I've been working on a script substitute (using SimSets) for the array resource, for those people who will be buying TGB sans source (only to discover that true key/value arrays are inexplicably MIA); but am only half done. Something that is so simple to do in C is quite hard to do in torquescript (when you need it to work in all cases).

If you're lucky enough to have access to the source, use the array resource. It has been around since October of 2003; and works beautifully. [I don't understand why such a thoroughly-tested resource wasn't included in the engine.]
#4
06/21/2006 (5:10 pm)
If anyone is interested, I wrote up an all script QuickSort algorithm. It uses its own script array class. I can post it as a resource if anyone wants it.
#5
06/21/2006 (7:33 pm)
William... Every additional TDN resource will prove invaluable to someone.