You could do something line by line:
1. add original index ref so [[1,0],[2,1],[3,2],[1,3],[1,4]... 2. sort on [:,0] 3. use np.where(ra[1:,0] != ra[:-1,0]) 4. use the list of indexes from above to construct your final list of lists
EDIT - OK, so after my quick reply I left a long time ago and I see that they voted for me, which is true, since numpy.argsort() much better than my suggestion. I voted for numpy.unique() answer, as this is an interesting feature. However, if you use timeit, you will find that
idx_start = np.where(sorted_records_array[:-1] != sorted_records_array[1:])[0] + 1 res = np.split(idx_sort, idx_start)
a little faster than
vals, idx_start = np.unique(sorted_records_array, return_index=True) res = np.split(idx_sort, idx_start[1:])
Next edit the following question @Nicolas
I'm not sure you can. It would be possible to get two arrays of indexes according to break points, but you cannot split different "lines" of the array into pieces of different sizes using np.split, therefore
a = np.array([[4,27,42,12, 4 .. 240, 12], [3,65,23...] etc]) idx = np.argsort(a, axis=1) sorted_a = np.diagonal(a[:, idx[:]]).T idx_start = np.where(sorted_a[:,:-1] != sorted_a[:,1:]) # idx_start => (array([0,0,0,..1,1,..]), array([1,4,6,7..99,0,4,5]))
but it can be good enough, depending on what you want to do with the information.