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

builtin: check array.sort_with_compare() arg mismatch (#11385)

This commit is contained in:
yuyi
2021-09-04 20:02:05 +08:00
committed by GitHub
parent 9b983bdd95
commit 5181031480
3 changed files with 30 additions and 2 deletions

View File

@ -146,11 +146,11 @@ pub fn (a array) repeat_to_depth(count int, depth int) array {
}
// sort_with_compare sorts array in-place using given `compare` function as comparator.
pub fn (mut a array) sort_with_compare(compare voidptr) {
pub fn (mut a array) sort_with_compare(callback fn (voidptr, voidptr) int) {
$if freestanding {
panic('sort does not work with -freestanding')
} $else {
unsafe { vqsort(a.data, size_t(a.len), size_t(a.element_size), compare) }
unsafe { vqsort(a.data, size_t(a.len), size_t(a.element_size), callback) }
}
}