emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master 4b79c80c999 1/2: New function 'sort-on'


From: Michael Heerdegen
Subject: Re: master 4b79c80c999 1/2: New function 'sort-on'
Date: Fri, 02 Feb 2024 17:43:11 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Daniel Mendler via "Emacs development discussions."
<emacs-devel@gnu.org> writes:

> Right. It is not pretty that some operations in seq.el do not generalize
> to infinite sequences.

The current situation is that `seq-sort' is only implemented for lists
and arrays, i.e. "sequences" in the narrow sense of the Elisp manual.
All types are transformed into a list and use the "sort" algorithm for
lists, and then the results are transformed back into the original type.
That's not such a useful abstraction, but ok...

> I would find it better if a similar function is not duplicated in
> multiple files, which would be the case if both `sort-on' and
> `seq-sort-on' are added.

It's worse: we already have `seq-sort-on': it's called `seq-sort-by'
which is a `sort-on' but not as efficient when the key function is not
trivial.

> > But do you really think people often would "sort-on" anything but lists?
>
> Yes. Sorting vectors is a useful operation. If the function is not added
> to seq.el it should maybe operate on the list or vector in a destructive
> manner for efficiency?

That's probably your field, I dunno.  If there is a key function that is
not cheap, the difference is probably not worth it.  Without a key
function this is a separate question, and the solution ... wait: `sort'
already does sort vectors, right?

Michael.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]