[Numpy-discussion] why sort does not accept a key?

2014-03-24 Thread Alan G Isaac
I'm wondering if `sort` intentially does not accept a `key` or if this is just a missing feature? (I suppose that if the `order` argument is specified it would have to accept a sequence of keys ...) Thanks, Alan Isaac ___ NumPy-Discussion mailing list

Re: [Numpy-discussion] why sort does not accept a key?

2014-03-24 Thread Alexander Belopolsky
On Mon, Mar 24, 2014 at 11:32 AM, Alan G Isaac alan.is...@gmail.com wrote: I'm wondering if `sort` intentionally does not accept a `key` or if this is just a missing feature? It would be very inefficient to call a key function on every element compared during the sort. See np.argsort and

Re: [Numpy-discussion] why sort does not accept a key?

2014-03-24 Thread Alan G Isaac
On Mon, Mar 24, 2014 at 11:32 AM, Alan G Isaac wrote: I'm wondering if `sort` intentionally does not accept a `key` or if this is just a missing feature? On 3/24/2014 11:47 AM, Alexander Belopolsky wrote: It would be very inefficient to call a key function on every element

Re: [Numpy-discussion] why sort does not accept a key?

2014-03-24 Thread josef . pktd
On Mon, Mar 24, 2014 at 12:08 PM, Alan G Isaac alan.is...@gmail.com wrote: On Mon, Mar 24, 2014 at 11:32 AM, Alan G Isaac wrote: I'm wondering if `sort` intentionally does not accept a `key` or if this is just a missing feature? On 3/24/2014 11:47 AM, Alexander Belopolsky wrote:

Re: [Numpy-discussion] why sort does not accept a key?

2014-03-24 Thread Alan G Isaac
On Mon, Mar 24, 2014 at 12:08 PM, Alan G Isaac what is the preferred idiom for a descending sort? On 3/24/2014 12:13 PM, josef.p...@gmail.com wrote: adding [::-1] just creates a new view, pretty low cost. I meant when you need to sort on a key (another vector). Currently I'm just reversing

Re: [Numpy-discussion] why sort does not accept a key?

2014-03-24 Thread Charles R Harris
On Mon, Mar 24, 2014 at 11:05 AM, Alan G Isaac alan.is...@gmail.com wrote: On Mon, Mar 24, 2014 at 12:08 PM, Alan G Isaac what is the preferred idiom for a descending sort? On 3/24/2014 12:13 PM, josef.p...@gmail.com wrote: adding [::-1] just creates a new view, pretty low cost. I

Re: [Numpy-discussion] why sort does not accept a key?

2014-03-24 Thread Alan G Isaac
On 3/24/2014 1:41 PM, Charles R Harris wrote: For float types you would need to use the negative. Yes, that's all I could come up with. So ... shd `sort` have a `reverse` option, like Python's builtin? Alan ___ NumPy-Discussion mailing list

Re: [Numpy-discussion] why sort does not accept a key?

2014-03-24 Thread Charles R Harris
On Mon, Mar 24, 2014 at 11:57 AM, Alan G Isaac alan.is...@gmail.com wrote: On 3/24/2014 1:41 PM, Charles R Harris wrote: For float types you would need to use the negative. Yes, that's all I could come up with. So ... shd `sort` have a `reverse` option, like Python's builtin? Well, it