How would I go about sorting an array of objects based on a specified property. For instance, if I had an array of movie objects called Movie[] movies, and the movie class had the properties
String title, int popularity, and Date releaseDate, how would I go about writing methods that sort the array based on either title, popularity, or releaseDate?
For instance, I have this class which compares the releaseDate of two rentals:
I also have a compareTo method in the Rentals class (which is the superclass for Movies and implements Comparable) which compares two strings(titles).
How do I implement Arrays.sort for these two types of comparison methods?
Thanks!