(Or, how do I implement the Ordered trait in a custom class so I can use the sorted method (or operators like <, <=, >, and >=) to compare instances of my class?
...
The sorted method can sort collections with type Double, Float, Int, and any other type that has an implicit scala.math.Ordering:
scala>val a = List(10, 5, 8, 1, 7).sorted a: List[Int] = List(1, 5, 7, 8, 10) scala>val b = List("banana", "pear", "apple", "orange").sorted b: List[String] = List(apple, banana, orange, pear)
The "rich" versions of the numeric classes (like RichInt) and the StringOps class all extend the Ordered trait, so they can be used with the sorted method.