Order Contacts With compareTo on Two Fields
mediumQuestion 533Contact already says it implements Comparable<Contact>, but the method that interface requires is missing, so the class does not compile yet. Write compareTo so that sorting puts contacts in phone-book order.
Requirements:
1. compareTo(Contact other) orders contacts by lastName, alphabetically.
2. When two last names are equal, the firstName decides, alphabetically.
3. Return a negative number when this contact comes first, a positive number when it comes after, and zero only when both names match.
4. String already has a compareTo method that orders text alphabetically. Use it and do not compare characters yourself.
5. Do not change the fields, the constructor or toString().
Do NOT write a main method.
Expected output
Adams, Ravi Baker, Lena Stone, Alex Stone, Mina
= newline. The output ends with a newline, so print one after the last line.
Your output
Run your code to see the output here...