Wednesday, June 25, 2014

Re: Sorting a List of Numbers

Christian wrote:

> > > On Di, 10 Jun 2014, Павлов Николай Александрович wrote:
> > >
> > > > How would you sort a heterogeneous list otherwise?
> > >
> > > Who says, lists are always heterogeneous? I think one could try to sort
> > > numerical, if all list items are of type number or float, else keep the
> > > existing sorting order.
> >
> > It's just that when the sort() function was added the main purpose was
> > to sort text. From that the idea was added to turn anything into text
> > to be able to sort that too.
> >
> > Obviously we would need to add another sort function, or a special
> > argument to the existing sort function, to have it convert everything to
> > a number and sort that. Text and other non-numbers would be used as
> > zero, just slightly better than reporting an error.
> >
> > We already have the special case for the {func} argument to ignore case
> > when it's one. Could use the same flags as the :sort command has.
>
> So how about the attached patch.

Thanks! Glad to see it was not too complicated.

--
DEAD PERSON: I don't want to go in the cart!
CUSTOMER: Oh, don't be such a baby.
MORTICIAN: I can't take him...
DEAD PERSON: I feel fine!
CUSTOMER: Oh, do us a favor...
MORTICIAN: I can't.
The Quest for the Holy Grail (Monty Python)

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: