class X def main is shared X().run def run # trying not to use features not tested at this point in the test suite: # list = [2, 1, 3] list = .makeList list.sort(ref .compare) assert list == [1, 2, 3] list.sort(ref .reverseCompare) assert list == [3, 2, 1] # in the future, inline delegate expressions and type inference: # list.sort(def(x as int, y as int) = y.compareTo(x)) # list.sort(def(x, y) = y.compareTo(x)) def compare(x as int, y as int) as int is shared return x.compareTo(y) def reverseCompare(x as int, y as int) as int is shared return y.compareTo(x) def makeList as List t = List() t.add(2) t.add(1) t.add(3) return t