How is the lexicographic order defined in Java especially in reference to special characters like !
, .
and so on?
An examplary order can be fou
Hope this helps!!
Employee sorted based on the descending order of the score and if two different employee has same score, then we need to consider Employee name for sorting lexicographically.
Employee class implementation: (Used Comparable interface for this case.)
@Override
public int compareTo(Object obj) {
Employee emp = (Employee) obj;
if(emp.getScore() > this.score) return 1;
else if(emp.getScore() < this.score) return -1;
else
return emp.getEmpName().compareToIgnoreCase(this.empName) * -1;
}