New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a &key option to the order command #1570
Comments
Other prior art is the Python
If the same optimization is done in Elvish then that clearly makes a P.S., I can't help proposing that |
@krader1961 Yeah, I thought of that optimization too, but neglected to mention it, as I was in a rush to leave. Of course, it comes at a slight cost in space in order to save time, but that is probably not a strong argument against it. In any case,, that is easily resolved by writing a bit more go code, so the optimization is not applied when Below is an elvish implementation using this optimization. Incidentally, while testing it, I discovered that the documentation for
|
This is because the value assignable to
That could be changed to allow any value and add a test for On the other hand, the option handling framework could be modified to allow |
It turned out to be simpler than I expected to support |
My earlier benchmark results made the
|
I was waiting for my earlier change to support comparing boolean values to be merged before creating a pull-request for this feature. Now that comparing booleans is possible (see issue #1585) I'll proceed with creating a pull-request to resolve this issue. |
The
order
command currently has the option&less-than
, which should be a function to be called with two values from the list to be ordered in order to determine is the first is to be placed before the second.In applications, the supplied function often needs to extract or compute a sort key from each of the two list item, and then compare the keys. This can lead to extra verbosity, code that is harder to read. and a (somewhat) higher risk of bugs.
The proposal is inspired by the Common Lisp
sort
functiuon, which has such an option. It was recently discussed briefly in chat.For reference, here is a simple elvish implementation of the proposal.
Example usage:
The text was updated successfully, but these errors were encountered: