Sorting DGArray pointers INLINE

Previous topic - Next topic

MrTAToad

I have an DGArray of structure pointers :

Code (glbasic) Select
DGArray<WINDOW_ZPOS_ORDER *> windowsZPos;

which should be used for sorting my structures (with the appropriate operator overloads in the structure).

However, I find that SORTARRAY will not sort this array list by the contents (although I suspect it is sorting it by memory location), although it will if it's an array of structures.  Is there a way of getting the structure pointers to be sorted by the contents ?

The only way I can think of doing it would be to put the pointers (and overloads) into a structure.

Kitty Hello

Yes. You must supply a compare function that compares the values of the ptrs.

MrTAToad

By the way, how would you pass SORTARRAY a C compare function - currently I overload the  < and > operators, but there may be times when a comparision routine would be better

Kitty Hello

Just make a glbasic compare function and copy the generated syntax.

MrTAToad