Sorting Arrays of Objects

Can you show the declaration of the Array and how you call sort, so people can check?

Just the basic stuff.

OwnedArray<WLoopPart> theArray;

WLoopPartElementComparator sorter

Something like that. I already erased the code and will do my own sorter. :frowning:

But thanks for the help. (hug)

I would assume OwnedArray contains pointers, so a comparison function/object that takes in references for the elements to compare isn’t going to work.

From the OwnedArray docs…

Sorts the elements in the array.

This will use a comparator object to sort the elements into order. The object passed must have a method of the form:

int compareElements (ElementType* first, ElementType* second);

(facepalm) (shameface) thanks guys… I’m getting old faster… :-p

1 Like