Arbitrary concomitants in the prescence of duplicates
jorenham opened this issue · 1 comments
This can be solved with either np.lexsort
or np.argsort
+ structured type's. So a small performance test is requires to select the best of the two.
Alternatively, a post-sort check can quickly be done to identify (consecutive) duplicate values. These sub-array's can then individually be re-ordered, using the concomitant's ordering. But I suspect this to be a lot slower that the other two options.
Secret option no. 4: np.argsort(x + y * 1j)
Because, since numpy 1.4, np.argsort
accepts complex numbers:
The sort order for complex numbers is lexicographic. If both the real and imaginary parts are non-nan then the order is determined by the real parts except when they are equal, in which case the order is determined by the imaginary parts.