Robert Webb wrote:

> 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?

-- 
A consultant is a person who takes your money and annoys your employees while
tirelessly searching for the best way to extend the consulting contract.
                                (Scott Adams - The Dilbert principle)

 /// 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.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui