I've replicated using 1d array argsort that can matches with lexsort.
#a = 1d np.array
#b = 1d np.array
def lexsort_copy(a,b):
idxs= np.argsort(a,kind='stable')
return idxs[np.argsort(b[idxs],kind='stable')]
lexsort_copy(a,b) == np.lexsort((a,b))
which gives me the same output, but I am struggling how to replicate this using 2d array.
test 2d array:
test=np.array([[100,100,100,100,111,400,120],[229,1133,152,210,120,320,320]])
np.lexsort(test)
output:
array([4, 2, 3, 0, 6, 5, 1], dtype=int64)
how can we replicate this above output without using lexsort for 2d array?
Any solution here would be appreciated! Thank you!
from his mujjjga's answer i was able to fine one array that does not work
np.array([100,100,100,100,111,111,90],
[102,102,102,102,102,102,102],
[150,150,150,150,95,95,95]])