Bram replied:

> > The help for sort() says the following with respect to the function
> > reference argument:
> > 
> >     ...The function is invoked with two
> >     items as argument and must return zero if they are equal, 1 if
> >     the first one sorts after the second one, -1 if the first one
> >     sorts before the second one.  Example:
> >             func MyCompare(i1, i2)
> >                return a:i1 == a:i2 ? 0 : a:i1 > a:i2 ? 1 : -1
> >             endfunc
> > 
> > Does it really have to return -1, 0, or 1?  Or is it OK to just return
> > negative, 0 or positive?  That way it becomes easier:
> > 
> >             func MyCompare(i1, i2)
> >            return a:il - a:i2
> >             endfunc
> > 
> > I think the docs should be updated if this is how it behaves.  And if
> > not, the docs and the code should be updated so it does :-)
> 
> Vim uses qsort().  My man page says that the value of the compare
> function can be any value less than, equal to or bigger than zero.
> Is it like that on all systems?

I believe it's the same on all systems.  qsort() just compares the sign.

Maybe it should say:

    The function is invoked with two items as argument and must return
    an integer: zero if they are equal, positive if the first one
    should sort after the second, or negative if the first one should sort
    before the second.

Rob.

--

Robert Webb <[EMAIL PROTECTED]>,
MineSweeper3D - Take Minesweeper to a whole new dimension!
http://www.software3d.com/Mines3D

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui