Notifications
Clear all

[Closed] Sorting maxObjectTab arrays

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?
:¬/

3 Replies
1 Reply
(@robgalanakis)
Joined: 11 months ago

Posts: 0

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).

 PEN

I have just been writing that a bunch lately and I have to collect the items and then pass that to qsort.

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?