From: Charles R H. <cha...@gm...> - 2006-09-19 19:58:08
|
On 9/19/06, Bill Baxter <wb...@gm...> wrote: > > On 9/20/06, Francesc Altet <fa...@ca...> wrote: > > A Dimarts 19 Setembre 2006 19:21, Charles R Harris va escriure: > > > > > > Do you want both the indexes and index sorted array returned, or just > sort > > > the array using indexes, i.e., something like > > > > > > a.sort(kind="quicksort", method="indirect") > > > > Uh, I don't understand what do you mean by "sort the array using > indexes", > > sorry. > > > > I think he meant do an argsort first, then use fancy indexing to get > the sorted array. > For a 1-d array that's just > > ind = A.argsort() > Asorted = A[ind] > > That should be O(N lg N + N), aka O(N lg N) > For A >1-d, you need an indexing expression that's a little more > complicated, hence the discussion about making an "extract" function > for that purpose. Then you could say: > > ind = A.argsort(axis=d) > Asorted = A.extract(ind,axis=d) I'm also thinking of the name argtake. Chuck |