scala> val ll = List(1,2,3,5,5)
ll: List[Int] = List(1, 2, 3, 5, 5)

scala> ll.take(2)
res3: List[Int] = List(1, 2)

scala> def compare(a:Int, b:Int):Boolean = {
     |   println("comparing %s and %s".format(a,b))
     |   a>b
     | }
compare: (a: Int, b: Int)Boolean

scala> compare(33,11)
comparing 33 and 11
res4: Boolean = true

scala> ll.sortWith(compare)
comparing 2 and 1
comparing 3 and 2
comparing 5 and 3
comparing 5 and 5
comparing 5 and 5
comparing 5 and 2
comparing 5 and 3
comparing 5 and 5
comparing 5 and 5
res5: List[Int] = List(5, 5, 3, 2, 1)

scala> List(10, 5, 8, 1, 7).sortWith(_ < _)
res1: List[Int] = List(1, 5, 7, 8, 10)