View Full Version : Sorting maxObjectTab arrays
Chinwagon 09-19-2008, 02:03 AM I've got an array of objects stored in a custom attribute maxObjectTab and I wish to sort them by their names. Weirdly though, sort and qsort don't work as they don't accept it as an array.
Anyone done this sort of stuff before?
:¬/
|
|
RobGalanakis
09-19-2008, 02:53 AM
I've got an array of objects stored in a custom attribute maxObjectTab and I wish to sort them by their names. Weirdly though, sort and qsort don't work as they don't accept it as an array.
Anyone done this sort of stuff before?
:¬/
Array parameters are actually ArrayParameters, not arrays (check the help file). It basically means they can only store one type of data, and some array functions don't work.
You can cast an ArrayParameter as an array (since Max6 I believe), sort it, and assign it to the parameter tab. You may also be able to write your own sorting algorithm to shuffle stuff in-place (not sure though).
I have just been writing that a bunch lately and I have to collect the items and then pass that to qsort.
Chinwagon
09-19-2008, 01:26 PM
Is the best way to sort the array before I store in the maxObjectTab array? Create a temporary array from the objects out of the maxObjectTab array, sort them by name and replace the maxObjectTab array with the sorted array?
CGTalk Moderation
09-19-2008, 01:26 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.