doc: port changes for locale-based :sort

Cherry-picked from 3132cddd20.
This commit is contained in:
Sean Dewar 2021-04-20 01:39:19 +01:00
parent b530221126
commit eef5a627bf
No known key found for this signature in database
GPG Key ID: 08CC2C83AD41B581
2 changed files with 26 additions and 14 deletions

View File

@ -1750,13 +1750,15 @@ 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.
With [l] sort uses the current collation locale.
Implementation details: strcoll() is used to compare
strings. See |:language| to check or set the collation
locale. Example: >
:language collate en_US.UTF-8
:%sort l
< |v:collate| can also used to check the current locale.
Sorting using the locale typically ignores case.
This does not work properly on Mac.
Options [n][f][x][o][b] are mutually exclusive.

View File

@ -8359,15 +8359,25 @@ 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 'l' then the current collation
locale is used for ordering. Implementation details: strcoll()
is used to compare strings. See |:language| check or set the
collation locale. |v:collate| can also be used to check the
current locale. Sorting using the locale typically ignores
case. Example: >
" ö is sorted similarly to o with English locale.
:language collate en_US.UTF8
:echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l')
< ['n', 'o', 'O', 'ö', 'p', 'z'] ~
>
" ö is sorted after z with Swedish locale.
:language collate sv_SE.UTF8
:echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l')
< ['n', 'o', 'O', 'p', 'z', 'ö'] ~
This does not work properly on Mac.
When {func} is given and it is 'n' then all items will be
sorted numerical (Implementation detail: This uses the
sorted numerical (Implementation detail: this uses the
strtod() function to parse numbers, Strings, Lists, Dicts and
Funcrefs will be considered as being 0).