mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-11 06:08:41 +01:00
Added List.sort(comp) to List module (#802)
This commit is contained in:
9
test/core/list/sort.wren
Normal file
9
test/core/list/sort.wren
Normal file
@ -0,0 +1,9 @@
|
||||
System.print([4, 1, 3, 2].sort()) // expect: [1, 2, 3, 4]
|
||||
|
||||
var l = [10, 7, 8, 9, 1, 5]
|
||||
l.sort{|a, b| a < b }
|
||||
System.print(l) // expect: [1, 5, 7, 8, 9, 10]
|
||||
l.sort{|a, b| a > b }
|
||||
System.print(l) // expect: [10, 9, 8, 7, 5, 1]
|
||||
|
||||
[10, 7, 8, 9, 1, 5].sort(3) // expect runtime error: Comparer must be a function.
|
||||
Reference in New Issue
Block a user