Defined a class named Person and mix it with Ordered Trait to do the comparison. First, checked if the name parameter of both objects is equal. If yes, then do the compare according to age. If the name is not equal then do the comparison based on name length.
class Person(val name: String, val age: Int) extends Ordered[Person]{ }
For example: Input: personOne = new Person("Test", 24) and personTwo = new Person("Test", 25) personOne < personOne Output: true
Input: personOne = new Person("TestAgain", 24) and personTwo = new Person("Test", 25) personOne < personOne Output: false