cgen,builtin: fix sort for []u64
parent
29857cb9d6
commit
b99ea332f0
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue