diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-11-01 13:57:44 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-11-01 13:57:44 +0100 |
commit | 55e29611d20bca14fa5efc61385bc8a6b7acd9e2 (patch) | |
tree | ab93029caf0fe68c139d7b7d02c67fe11abf02b7 /runtime | |
parent | 963734e316bd17dd7290abcac28b875435d06381 (diff) | |
download | vim-git-8.2.1933.tar.gz |
patch 8.2.1933: cannot sort using locale orderingv8.2.1933
Problem: Cannot sort using locale ordering.
Solution: Add a flag for :sort and sort() to use the locale. (Dominique
Pellé, closes #7237)
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/change.txt | 13 | ||||
-rw-r--r-- | runtime/doc/eval.txt | 7 |
2 files changed, 17 insertions, 3 deletions
diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt index fe62d1d95..12e20a5ab 100644 --- a/runtime/doc/change.txt +++ b/runtime/doc/change.txt @@ -1801,7 +1801,7 @@ Vim has a sorting function and a sorting command. The sorting function can be found here: |sort()|, |uniq()|. *:sor* *:sort* -:[range]sor[t][!] [b][f][i][n][o][r][u][x] [/{pattern}/] +:[range]sor[t][!] [b][f][i][l][n][o][r][u][x] [/{pattern}/] Sort lines in [range]. When no range is given all lines are sorted. @@ -1809,6 +1809,14 @@ found here: |sort()|, |uniq()|. With [i] case is ignored. + With [l] sort uses the current locale. See + `language collate` to check or set the locale used + for ordering. For example, with "en_US.UTF8", + Ö will be ordered after O and before P, + whereas with the Swedish locale "sv_SE.UTF8", + it will be after Z. + Case is typically ignored by the locale. + Options [n][f][x][o][b] are mutually exclusive. With [n] sorting is done on the first decimal number @@ -1875,8 +1883,7 @@ found here: |sort()|, |uniq()|. Note that using `:sort` with `:global` doesn't sort the matching lines, it's quite useless. -The details about sorting depend on the library function used. There is no -guarantee that sorting obeys the current locale. You will have to try it out. +`:sort` does not use the current locale unless the l flag is used. Vim does do a "stable" sort. The sorting can be interrupted, but if you interrupt it too late in the diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index b757e5f2f..e487d3e28 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -9700,6 +9700,13 @@ sort({list} [, {func} [, {dict}]]) *sort()* *E702* When {func} is given and it is '1' or 'i' then case is ignored. + When {func} is given and it is 'l' then the current locale + is used for ordering. See `language collate` to check or set + the locale used for ordering. For example, with "en_US.UTF8", + Ö will be ordered after O and before P, whereas with the + Swedish locale "sv_SE.UTF8", it will be after Z. + Case is typically ignored by the locale. + When {func} is given and it is 'n' then all items will be sorted numerical (Implementation detail: This uses the strtod() function to parse numbers, Strings, Lists, Dicts and |