cgen,builtin: fix sort for []u64

pull/7152/head
Delyan Angelov 2020-12-05 23:14:14 +02:00
parent 29857cb9d6
commit b99ea332f0
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 23 additions and 0 deletions

View File

@ -531,6 +531,26 @@ fn compare_ints_reverse(a &int, b &int) int {
return 0
}
fn compare_u64s(a &u64, b &u64) int {
if *a < *b {
return -1
}
if *a > *b {
return 1
}
return 0
}
fn compare_u64s_reverse(a &u64, b &u64) int {
if *a > *b {
return -1
}
if *a < *b {
return 1
}
return 0
}
fn compare_floats(a &f64, b &f64) int {
if *a < *b {
return -1

View File

@ -4866,6 +4866,9 @@ fn (mut g Gen) gen_array_sort(node ast.CallExpr) {
table.int_type {
compare_fn = 'compare_ints'
}
table.u64_type {
compare_fn = 'compare_u64s'
}
table.string_type {
compare_fn = 'compare_strings'
}