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 chris.bar...@noaa.gov 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 ben.r...@ou.edu wrote: While that may work for this

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 n...@pobox.com wrote: On Tue, Jun 5, 2012 at 1:17 AM, Benjamin Root ben.r...@ou.edu wrote: On Monday, June 4, 2012, Chris Barker wrote: On Mon, Jun 4, 2012 at 11:10 AM, Patrick Redmond plredm...@gmail.com wrote: Here's how I sorted

[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

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',

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 plredm...@gmail.com 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,

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 plredm...@gmail.comjavascript:; 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