Originally Posted by
brewbuck
Then you must have a bug in your sorting algorithm. Look more carefully at my comparison function.
For two elements with unequal z, the one with lower z will come first.
For two elements with EQUAL z, the one with lower t will come first.
Obviously, for a given z0, all elements where z <= z0 will come before elements where z > z0. We can then consider the groups z <= z0 and z > z0 independently. Within these groups, the same argument can be applied, until we have divided all the elements into groups with equal z.
Then, within these groups, it is obvious that the ordering will be by t.
This is nothing more than lexical ordering. An "alphabetic sort", where the first letter is the z value, and the second letter is the t value.