1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: fix array sort error (#11046)

This commit is contained in:
yuyi
2021-08-04 11:31:57 +08:00
committed by GitHub
parent 2eb11110d6
commit b870f7a6f1
2 changed files with 26 additions and 2 deletions

View File

@ -897,6 +897,24 @@ fn test_i64_sort() {
assert f[6] == 79
}
fn test_a_b_paras_sort() {
mut arr_i := [1, 3, 2]
arr_i.sort(a < b)
println(arr_i)
assert arr_i == [1, 2, 3]
arr_i.sort(b < a)
println(arr_i)
assert arr_i == [3, 2, 1]
mut arr_f := [1.1, 3.3, 2.2]
arr_f.sort(a < b)
println(arr_f)
assert arr_f == [1.1, 2.2, 3.3]
arr_f.sort(b < a)
println(arr_f)
assert arr_f == [3.3, 2.2, 1.1]
}
/*
fn test_for_last() {
numbers := [1, 2, 3, 4]