Re: [Numpy-discussion] 1D array sorting ascending and descending by fields

2012-06-05 Thread Benjamin Root
On Tue, Jun 5, 2012 at 10:49 AM, Nathaniel Smith wrote: > On Tue, Jun 5, 2012 at 1:17 AM, Benjamin Root wrote: > > > > > > On Monday, June 4, 2012, Chris Barker wrote: > >> > >> On Mon, Jun 4, 2012 at 11:10 AM, Patrick Redmond > >> wrote: > >> > Here's how I sorted primarily by field 'a' descen

Re: [Numpy-discussion] 1D array sorting ascending and descending by fields

2012-06-05 Thread Nathaniel Smith
On Tue, Jun 5, 2012 at 1:17 AM, Benjamin Root wrote: > > > On Monday, June 4, 2012, Chris Barker wrote: >> >> On Mon, Jun 4, 2012 at 11:10 AM, Patrick Redmond >> wrote: >> > Here's how I sorted primarily by field 'a' descending and secondarily by >> > field 'b' ascending: >> >> could you multiply

Re: [Numpy-discussion] 1D array sorting ascending and descending by fields

2012-06-05 Thread Patrick Redmond
On Mon, Jun 4, 2012 at 6:08 PM, Chris Barker wrote: > could you multiply the numeric field by -1, sort, then put it back > Yeah, that works great for my situation. Thanks Chris! On Mon, Jun 4, 2012 at 8:17 PM, Benjamin Root wrote: > While that may work for this users case, that would not work fo

Re: [Numpy-discussion] 1D array sorting ascending and descending by fields

2012-06-04 Thread Benjamin Root
On Monday, June 4, 2012, Chris Barker wrote: > On Mon, Jun 4, 2012 at 11:10 AM, Patrick Redmond > > > wrote: > > Here's how I sorted primarily by field 'a' descending and secondarily by > > field 'b' ascending: > > could you multiply the numeric field by -1, sort, then put it back -- > somethign

Re: [Numpy-discussion] 1D array sorting ascending and descending by fields

2012-06-04 Thread Chris Barker
On Mon, Jun 4, 2012 at 11:10 AM, Patrick Redmond wrote: > Here's how I sorted primarily by field 'a' descending and secondarily by > field 'b' ascending: could you multiply the numeric field by -1, sort, then put it back -- somethign like: data *- -1 data_sorted = np.sort(data, order=['a','b'])

Re: [Numpy-discussion] 1D array sorting ascending and descending by fields

2012-06-04 Thread Patrick Redmond
Here's how I sorted primarily by field 'a' descending and secondarily by field 'b' ascending: (Note that 'a' is the second column, 'b' is the first) >>> data array([('b', 0.03), ('c', 0.03), ('f', 0.03), ('e', 0.01), ('d', 0.04), ('a', 0.04)], dtype=[('b',

[Numpy-discussion] 1D array sorting ascending and descending by fields

2012-06-04 Thread Patrick Redmond
Hi! I have a one-dimensional ndarray with two fields. I'd like to sort in descending order by field 'a', breaking ties by sorting in ascending order by field 'b'. I've found combinations of sorting and reversing followed by stable sorting that work, but there must be a straightforward way to do i