mirror of
https://github.com/vlang/v.git
synced 2025-09-15 07:22:27 +03:00
checker: check array.sort(a < b) (#9321)
This commit is contained in:
parent
2991cad4e8
commit
dd9f9c2718
4 changed files with 79 additions and 52 deletions
|
@ -24,18 +24,18 @@ fn test_sorting_primitives_with_condition_expression() {
|
|||
assert x == ['9', '87', '654', '3210']
|
||||
}
|
||||
|
||||
fn get_score(word string) int {
|
||||
mut total := 0
|
||||
for letter in word {
|
||||
total += int(letter) - 97
|
||||
}
|
||||
return total
|
||||
}
|
||||
// fn get_score(word string) int {
|
||||
// mut total := 0
|
||||
// for letter in word {
|
||||
// total += int(letter) - 97
|
||||
// }
|
||||
// return total
|
||||
// }
|
||||
|
||||
fn test_sorting_with_fn_call_in_condition_expression() {
|
||||
mut words := ['aaaa', 'a', 'b', 'foo', 'bar']
|
||||
words.sort(get_score(a) < get_score(b))
|
||||
}
|
||||
// fn test_sorting_with_fn_call_in_condition_expression() {
|
||||
// mut words := ['aaaa', 'a', 'b', 'foo', 'bar']
|
||||
// words.sort(get_score(a) < get_score(b))
|
||||
// }
|
||||
|
||||
fn mysort(mut a []int) {
|
||||
a.sort()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue