comparison runtime/doc/builtin.txt @ 27859:3cb1a109e987 v8.2.4455

patch 8.2.4455: accepting one and zero for second sort() argument is strange Commit: https://github.com/vim/vim/commit/2007dd49f5cb36f944cab1cfbceb0f864e625f74 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Feb 23 13:17:47 2022 +0000 patch 8.2.4455: accepting one and zero for second sort() argument is strange Problem: Accepting one and zero for the second sort() argument is strange. Solution: Disallow using one and zero in Vim9 script.
author Bram Moolenaar <Bram@vim.org>
date Wed, 23 Feb 2022 14:30:03 +0100
parents 8fc68ce4a097
children d19b7aee1925
comparison
equal deleted inserted replaced
27858:6197d182d707 27859:3cb1a109e987
537 simplify({filename}) String simplify filename as much as possible 537 simplify({filename}) String simplify filename as much as possible
538 sin({expr}) Float sine of {expr} 538 sin({expr}) Float sine of {expr}
539 sinh({expr}) Float hyperbolic sine of {expr} 539 sinh({expr}) Float hyperbolic sine of {expr}
540 slice({expr}, {start} [, {end}]) String, List or Blob 540 slice({expr}, {start} [, {end}]) String, List or Blob
541 slice of a String, List or Blob 541 slice of a String, List or Blob
542 sort({list} [, {func} [, {dict}]]) 542 sort({list} [, {how} [, {dict}]])
543 List sort {list}, using {func} to compare 543 List sort {list}, compare with {how}
544 sound_clear() none stop playing all sounds 544 sound_clear() none stop playing all sounds
545 sound_playevent({name} [, {callback}]) 545 sound_playevent({name} [, {callback}])
546 Number play an event sound 546 Number play an event sound
547 sound_playfile({path} [, {callback}]) 547 sound_playfile({path} [, {callback}])
548 Number play sound file {path} 548 Number play sound file {path}
8031 8031
8032 Can also be used as a |method|: > 8032 Can also be used as a |method|: >
8033 GetList()->slice(offset) 8033 GetList()->slice(offset)
8034 8034
8035 8035
8036 sort({list} [, {func} [, {dict}]]) *sort()* *E702* 8036 sort({list} [, {how} [, {dict}]]) *sort()* *E702*
8037 Sort the items in {list} in-place. Returns {list}. 8037 Sort the items in {list} in-place. Returns {list}.
8038 8038
8039 If you want a list to remain unmodified make a copy first: > 8039 If you want a list to remain unmodified make a copy first: >
8040 :let sortedlist = sort(copy(mylist)) 8040 :let sortedlist = sort(copy(mylist))
8041 8041
8042 < When {func} is omitted, is empty or zero, then sort() uses the 8042 < When {how} is omitted or is an string, then sort() uses the
8043 string representation of each item to sort on. Numbers sort 8043 string representation of each item to sort on. Numbers sort
8044 after Strings, |Lists| after Numbers. For sorting text in the 8044 after Strings, |Lists| after Numbers. For sorting text in the
8045 current buffer use |:sort|. 8045 current buffer use |:sort|.
8046 8046
8047 When {func} is given and it is '1' or 'i' then case is 8047 When {how} is given and it is 'i' then case is ignored.
8048 ignored. 8048 In legacy script, for backwards compatibility, the value one
8049 8049 can be used to ignore case. Zero means to not ignore case.
8050 When {func} is given and it is 'l' then the current collation 8050
8051 When {how} is given and it is 'l' then the current collation
8051 locale is used for ordering. Implementation details: strcoll() 8052 locale is used for ordering. Implementation details: strcoll()
8052 is used to compare strings. See |:language| check or set the 8053 is used to compare strings. See |:language| check or set the
8053 collation locale. |v:collate| can also be used to check the 8054 collation locale. |v:collate| can also be used to check the
8054 current locale. Sorting using the locale typically ignores 8055 current locale. Sorting using the locale typically ignores
8055 case. Example: > 8056 case. Example: >
8062 :language collate sv_SE.UTF8 8063 :language collate sv_SE.UTF8
8063 :echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l') 8064 :echo sort(['n', 'o', 'O', 'ö', 'p', 'z'], 'l')
8064 < ['n', 'o', 'O', 'p', 'z', 'ö'] ~ 8065 < ['n', 'o', 'O', 'p', 'z', 'ö'] ~
8065 This does not work properly on Mac. 8066 This does not work properly on Mac.
8066 8067
8067 When {func} is given and it is 'n' then all items will be 8068 When {how} is given and it is 'n' then all items will be
8068 sorted numerical (Implementation detail: this uses the 8069 sorted numerical (Implementation detail: this uses the
8069 strtod() function to parse numbers, Strings, Lists, Dicts and 8070 strtod() function to parse numbers, Strings, Lists, Dicts and
8070 Funcrefs will be considered as being 0). 8071 Funcrefs will be considered as being 0).
8071 8072
8072 When {func} is given and it is 'N' then all items will be 8073 When {how} is given and it is 'N' then all items will be
8073 sorted numerical. This is like 'n' but a string containing 8074 sorted numerical. This is like 'n' but a string containing
8074 digits will be used as the number they represent. 8075 digits will be used as the number they represent.
8075 8076
8076 When {func} is given and it is 'f' then all items will be 8077 When {how} is given and it is 'f' then all items will be
8077 sorted numerical. All values must be a Number or a Float. 8078 sorted numerical. All values must be a Number or a Float.
8078 8079
8079 When {func} is a |Funcref| or a function name, this function 8080 When {how} is a |Funcref| or a function name, this function
8080 is called to compare items. The function is invoked with two 8081 is called to compare items. The function is invoked with two
8081 items as argument and must return zero if they are equal, 1 or 8082 items as argument and must return zero if they are equal, 1 or
8082 bigger if the first one sorts after the second one, -1 or 8083 bigger if the first one sorts after the second one, -1 or
8083 smaller if the first one sorts before the second one. 8084 smaller if the first one sorts before the second one.
8084 8085