builtin: optimize array sort (#9570)

This commit is contained in:
yuyi 2021-04-03 18:16:18 +08:00 committed by GitHub
parent 5229428d91
commit 7f81702d81
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 119 deletions

View file

@ -836,7 +836,7 @@ fn test_sort_by_different_order_of_a_b() {
fn test_f32_sort() {
mut f := [f32(50.0), 15, 1, 79, 38, 0, 27]
f.sort_with_compare(compare_f32)
f.sort()
assert f[0] == 0.0
assert f[1] == 1.0
assert f[6] == 79.0
@ -844,7 +844,7 @@ fn test_f32_sort() {
fn test_f64_sort() {
mut f := [50.0, 15, 1, 79, 38, 0, 27]
f.sort_with_compare(compare_f64)
f.sort()
assert f[0] == 0.0
assert f[1] == 1.0
assert f[6] == 79.0
@ -852,7 +852,7 @@ fn test_f64_sort() {
fn test_i64_sort() {
mut f := [i64(50), 15, 1, 79, 38, 0, 27]
f.sort_with_compare(compare_i64)
f.sort()
assert f[0] == 0
assert f[1] == 1
assert f[6] == 79