Jun Takimoto wrote:

> 2014/06/26 01:07, Ben Fritz <fritzophre...@gmail.com> wrote:
> 
> > On Tuesday, June 24, 2014 10:39:28 AM UTC-5, Ben Fritz wrote:
> >> 
> >> I thought your sort could be done in Vim with 2 passes, but
> >> unfortunately it does not work:
> >> 
> >> sort r /^\d\+/
> >> sort! /.*#/
> >> 
> > 
> > Bram, any chance that a way to guarantee a stable sort could be included,
> 
> I guess the :sort command *is* stable (although the sort() function is not).
> If you look into ex_cmds.c, end of the function sort_compare(), lines 340-341:
> 
>     if (result == 0)
>         return (int)(l1.lnum - l2.lnum);
> 
> this indicates that if the two lines are "equal" by the current comparison,
> then just compare by the line number; this should result in the stable sort.

Ah, there is an idea.  For sort() pointers to the list items are put in
an array.  Thus the position in the array could be used in the same way
as the line number.  You could give it a try by changing item_compare()
in src/eval.c.

[...]


-- 
Vim is like Emacs without all the typing.  (John "Johann" Spetz)

 /// Bram Moolenaar -- b...@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_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to