Christian Brabandt wrote:
> Hi Charles!
>
> On Do, 14 Okt 2010, Charles Campbell wrote:
>
> > Bee wrote:
> >> On Oct 13, 10:00 pm, Bee<[email protected]> wrote:
> >>
> >>> On Oct 13, 6:56 pm, Charles E Campbell Jr<[email protected]>
> >>> wrote:
> >>>
> >>>> Bee wrote:
> >>>>
> >>>>> sort bug?
> >>>>>
> >>>
> >>>>> vim 7.3.27 Linux
> >>>>> vim 7.3.21 Mac 10.4.11
> >>>>>
> >>>
> >>>>> Select the lines between the rules (including the blank lines) and
> >>>>> sort:
> >>>>> '<,'>sort n
> >>>>>
> >>>
> >>>>> "--------1---------2---------3---------4---------5---------6----
> >>>>> xxx yyy: 0
> >>>>> xxx yyy: 1
> >>>>> xxx yyy: 2
> >>>>> xxx yyy: 3
> >>>>> xxx yyy: 4
> >>>>>
> >>>
> >>>>> xxx yyy: 5
> >>>>> xxx yyy: 6
> >>>>> xxx yyy: 7
> >>>>> xxx yyy: 8
> >>>>> xxx yyy: 9
> >>>>>
> >>>
> >>>>> "--------1---------2---------3---------4---------5---------6----
> >>>>>
> >>>
> >>>>> The result is:
> >>>>>
> >>>
> >>>>> "--------1---------2---------3---------4---------5---------6----
> >>>>> xxx yyy: 0
> >>>>>
> >>>
> >>>>> xxx yyy: 1
> >>>>> xxx yyy: 2
> >>>>> xxx yyy: 3
> >>>>> xxx yyy: 4
> >>>>> xxx yyy: 5
> >>>>> xxx yyy: 6
> >>>>> xxx yyy: 7
> >>>>> xxx yyy: 8
> >>>>> xxx yyy: 9
> >>>>> "--------1---------2---------3---------4---------5---------6----
> >>>>>
> >>>
> >>>>> I would expect this and it is what I get when using the shell:
> >>>>> '<,'>!sort -n
> >>>>>
> >>>
> >>>>> "--------1---------2---------3---------4---------5---------6----
> >>>>>
> >>>
> >>>>> xxx yyy: 0
> >>>>> xxx yyy: 1
> >>>>> xxx yyy: 2
> >>>>> xxx yyy: 3
> >>>>> xxx yyy: 4
> >>>>> xxx yyy: 5
> >>>>> xxx yyy: 6
> >>>>> xxx yyy: 7
> >>>>> xxx yyy: 8
> >>>>> xxx yyy: 9
> >>>>> "--------1---------2---------3---------4---------5---------6----
> >>>>>
> >>>
> >>>> I tried your example and was unable to duplicate the problem. Have you
> >>>> tried putting this in a file, say sort.test:
> >>>> vim -u NONE -N sort.test
> >>>> :%sort
> >>>>
> >>>
> >>>> I tried that, and I tried using V and selecting all the lines, and each
> >>>> time I got the "I would expect this..." result.
> >>>>
> >>> Thank you, I did not think to do "vim -u NONE -N" and...
> >>> I then get the expected result!
> >>> That means something in my vimrc is causing the sort problem.
> >>> I will remember to do that first next time.
> >>>
> >> Oops!
> >> I copied what you had done and that works, but that is not the case I
> >> was using.
> >>
> >> Try it selecting the lines and
> >>
> >> :'<,'>sort n
> >>
> >> Do not forget the "n" numeric sort option.
> >>
> >> With [n] sorting is done on the first decimal number
> >> in the line (after or inside a {pattern} match).
> >> One leading '-' is included in the number.
> >>
> >>
> > OK, now that I'm using sort n -- I can duplicate the behavior.
>
> Yes empty lines are considered as they would contain a zero. And in case
> another line has the same number, the original order would remain. In
> this case, the line with the 0 stays on top. (Really strange is the
> result, if you have an empty line, followed by a line containing a zero
> followed by an empty line.)
>
> Attached patch fixes that.
Thanks. The number is a long, thus SHRT_MIN is not the smallest number.
To avoid problems with old compilers I'll use MAXLNUM made negative.
Hmm, when there are negative numbers there is another problem, I'll see
if I can fix that as well... Ah, subtracting two longs and storing the
result in an int truncates the number.
--
FIRST HEAD: All right! All right! We'll kill him first and then have tea and
biscuits.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.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