Sorting in Scala: sorted method
Sorting in Scala is very similar to sorting in Java like Java's Comparable called Ordered and Java's Comparator called Ordering.
Ordered has the this.compareTo(that) method. But there is a little difference here, it has both compare() and compareTo() methods. comapre() is an abstract method and compareTo is defined to call the compare method. So you may think that compare is an alias for compareTo.
Ordering has compare(obj1, obj2) method.
Ordered is defined for Default Natural sorting whereas Ordering is defined for Total ordering or custom ordering.
let's understand the whole concept by example: