Re: [Numpy-discussion] stable sort on a recarray ?

2011-03-29 Thread butterw
sortind = np.argsort(x['name'], kind='mergesort'); x[sortind] The indirect sorting method that was suggested works for doing stable sort on recarrays / structured arrays based on a single-column. # It is necessary to specify kind='mergesort' because argsort is not stable: np.argsort(np.ones

[Numpy-discussion] stable sort on a recarray ?

2011-03-28 Thread butterw
What is the recommended way to perform a stable sort on a recarray / structured array ? In the following example, I want to sort on name, while retaining the existing order in the case of equal values: values = [('a', 1), ('a', 0), ('b', 2)] dtype = [('name', 'S10'), ('val', 'i4')] a = np.a