builtin: add more documentation (#13160)

This commit is contained in:
jeffmikels 2022-01-14 10:27:38 -05:00 committed by GitHub
parent 4660220f4c
commit 9329b6c8c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 223 additions and 40 deletions

View file

@ -843,6 +843,20 @@ fn test_sort() {
assert users[2].name == 'Peter'
}
fn test_sort_with_compare() {
mut a := ['hi', '1', '5', '3']
a.sort_with_compare(fn (a &string, b &string) int {
if a < b {
return -1
}
if a > b {
return 1
}
return 0
})
assert a == ['1', '3', '5', 'hi']
}
fn test_rune_sort() {
mut bs := [`f`, `e`, `d`, `b`, `c`, `a`]
bs.sort()