Sorting a multidimensional basearray

On 16/04/2014 at 13:16, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   R15 
Platform:   Windows  ;   
Language(s) :     C++  ;

Using a SortedArray is perfect for sorting values.
Now I like to have a BaseArray with points (x,y,z), so 3 dimension.
How to sort such a point (3 dimensional) array for example on x value.
So, the point with the lowest x value first, and so on.


On 16/04/2014 at 14:45, xxxxxxxx wrote:

In fact, it is easier than I thought.
Just define it as a vector and change the inline code.

class MySortedIntegerArray : public maxon::SortedArray<MySortedIntegerArray, maxon::BaseArray<Vector> >
		MySortedIntegerArray() {}
	// your sorted array must implement a LessThan() method
	static inline maxon::Bool LessThan(Vector a, Vector b)	{ return a.x < b.x; }
void SortedArrayDemo()
	MySortedIntegerArray test;