" Tests for the "sort()" function and for the ":sort" command.
source check.vim
func Compare1(a, b) abort
call sort(range(3), 'Compare2')
return a:a - a:b
endfunc
func Compare2(a, b) abort
return a:a - a:b
endfunc
func Test_sort_strings()
CheckNotMSWindows " FIXME: Why does this fail with MSVC?
" numbers compared as strings
call assert_equal([1, 2, 3], sort([3, 2, 1]))
call assert_equal([13, 28, 3], sort([3, 28, 13]))
call assert_equal(['A', 'O', 'P', 'a', 'o', 'p', 'Ä', 'Ô', 'ä', 'ô', 'Œ', 'œ'],
\ sort(['A', 'O', 'P', 'a', 'o', 'p', 'Ä', 'Ô', 'ä', 'ô', 'œ', 'Œ']))
call assert_equal(['A', 'a', 'o', 'O', 'p', 'P', 'Ä', 'Ô', 'ä', 'ô', 'Œ', 'œ'],
\ sort(['A', 'a', 'o', 'O', 'œ', 'Œ', 'p', 'P', 'Ä', 'ä', 'ô', 'Ô'], 'i'))
" This does not appear to work correctly on Mac.
if !has('mac')
if v:collate =~? '^\(en\|fr\)_ca.utf-\?8$'
" with Canadian English capitals come before lower case.
" 'Œ' is omitted because it can sort before or after 'œ'
call assert_equal(['A', 'a', 'Ä', 'ä', 'O', 'o', 'Ô', 'ô', 'œ', 'P', 'p'],
\ sort(['A', 'a', 'o', 'O', 'œ', 'p', 'P', 'Ä', 'ä', 'ô'
|