Files
linguist/samples/Monkey/sorting.monkey2
DoctorWhoof a4e6fc78c8 Added a few Monkey2 examples (#3811)
* Added Monkey2 (extension .monkey2) example

This compiles with the most up to date Monkey2 release (V1.1.06).

* Sorting example in Monkey2

* Add files via upload

* Gui example using the MojoX module
2018-01-11 09:23:54 +00:00

29 lines
457 B
Plaintext

'Showcases use of Lambda functions and Generics.
#Import "<std>"
Using std..
Function Main()
Local testStack := New Stack< MyObject >
For Local n := 1 To 20
Local newItem := New MyObject
newItem.depth = Rnd( 0, 100 )
testStack.Push( newItem )
Next
testStack.Sort( Lambda:Int( x:MyObject,y:MyObject )
Return x.depth<=>y.depth
End )
For Local n := Eachin testStack
Print( n.depth )
Next
End
Struct MyObject
Field depth := 0
End