compareTo is an int class method in Scala which is used to compare this with that operand. It is similar to the compare Method.
Returns: return -1 when Given_Value1 is less than Given_Value2. return 0 when both values are equal. return 1 when Given_Value1 is greater than Given_Value2.