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

Charles R Harris charlesr.harris at gmail.com
Mon Mar 24 14:58:09 EDT 2014


On Mon, Mar 24, 2014 at 11:57 AM, Alan G Isaac <alan.isaac at 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 would double the number of sorts if we kept them efficient with
efficient type specific compares. Alternatively, we could sort the reverse
option using less efficient compare function calls. I think whether or not
we add a reverse option should depend on how many want it. One potential
problem would be that the sort function pointers are built into
PyArray_ArrFuncs, and adding more might be problematic. That has been a
continuing source of pain, for instance in adding the partition and
binsearch  functions, so it might be worth just expanding that structure.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140324/f83c094e/attachment.html>


More information about the NumPy-Discussion mailing list