<div dir="auto">I agree with the idea of setting apart the parameter from python , "by" sounds like a good alternative<div dir="auto"><br></div><div dir="auto">Rakesh <br><div dir="auto"><br></div><div dir="auto"><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 1, 2020, 18:45 Sebastian Berg <<a href="mailto:sebastian@sipsolutions.net">sebastian@sipsolutions.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, 2020-07-01 at 12:48 -0700, Stephan Hoyer wrote:<br>
> On Wed, Jul 1, 2020 at 12:23 PM Sebastian Berg <<br>
> <a href="mailto:sebastian@sipsolutions.net" target="_blank" rel="noreferrer">sebastian@sipsolutions.net</a>><br>
> wrote:<br>
> <br>
> > This is a WIP, but allows nicely to try out how the new API<br>
> > could/should look like, and see the potential impact to code.  The<br>
> > current choice is for:<br>
> > <br>
> >     np.sort(arr, keys=(arr.real, arr.image))<br>
> > <br>
> > for example.  `keys` is like the `key` argument to pythons sorts,<br>
> > but<br>
> > unlike python sorts is not passed a function but rather a sequence<br>
> > of<br>
> > arrays.<br>
> > <br>
> > Alternative spellings could be `by=...`? Or maybe someone has a<br>
> > different API idea.<br>
> > <br>
> <br>
> I really like the look of np.sort(arr, by=(arr.real, arr.image)).<br>
> - This avoids adding an extra function sortby into NumPy's API. The<br>
> default<br>
> behavior (by=None) would of course be to sort by the arrays being<br>
> sorted,<br>
> so it's backwards compatible.<br>
> - Calling the new argument "by" instead of "key" avoids confusion<br>
> with the<br>
> behavior of Python's sort/sorted (which take functions instead of<br>
> sequences).<br>
<br>
<br>
I just noticed that `DataFrame.sort_values()` uses `by=...` with a list<br>
of column names.  However, I guess that is fairly compatible with this<br>
usage.<br>
<br>
- Sebastan<br>
<br>
<br>
> The combination of lexsort() and take_along_axis() makes it possible<br>
> to<br>
> achieve this behavior currently, but it is definitely less clear than<br>
> a<br>
> single function call.<br>
> _______________________________________________<br>
> NumPy-Discussion mailing list<br>
> <a href="mailto:NumPy-Discussion@python.org" target="_blank" rel="noreferrer">NumPy-Discussion@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><br>
<br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org" target="_blank" rel="noreferrer">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div>