Mercurial > vim
diff runtime/doc/eval.txt @ 7291:6ffc75d807bd v7.4.951
commit https://github.com/vim/vim/commit/b00da1d6d1655cb6e415f84ecc3be5ff3b790811
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Dec 3 16:33:12 2015 +0100
patch 7.4.951
Problem: Sorting number strings does not work as expected. (Luc Hermitte)
Solution: Add the 'N" argument to sort()
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 03 Dec 2015 16:45:05 +0100 |
parents | b5e9810b389d |
children | 444efa5f5015 |
line wrap: on
line diff
--- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -5803,6 +5803,10 @@ sort({list} [, {func} [, {dict}]]) *so strtod() function to parse numbers, Strings, Lists, Dicts and Funcrefs will be considered as being 0). + When {func} is given and it is 'N' then all items will be + sorted numerical. This is like 'n' but a string containing + digits will be used as the number they represent. + When {func} is a |Funcref| or a function name, this function is called to compare items. The function is invoked with two items as argument and must return zero if they are equal, 1 or @@ -5817,6 +5821,11 @@ sort({list} [, {func} [, {dict}]]) *so on numbers, text strings will sort next to each other, in the same order as they were originally. + The sort is stable, items which compare equal (as number or as + string) will keep their relative position. E.g., when sorting + on numbers, text strings will sort next to each other, in the + same order as they were originally. + Also see |uniq()|. Example: >