1
0
forked from Mirror/wren

Added List.sort(comp) to List module (#802)

This commit is contained in:
Mat Mariani
2020-12-03 14:59:07 -05:00
committed by GitHub
parent 08d2fa3821
commit 3d5e68fc01
4 changed files with 102 additions and 0 deletions

9
test/core/list/sort.wren Normal file
View 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.