mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builtin: add more documentation (#13160)
This commit is contained in:
@ -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()
|
||||
|
Reference in New Issue
Block a user