Cognizant interview question

How to re-write sort method in Java?

Interview Answer

Anonymous

Mar 1, 2019

Implement the Comparator interface and rewrite the compare method inside the object.