I want to sort these times in order:
4:05 AM
5:04 PM
6:04 AM
4:05 PM
5:04 AM
12:01 AM
12:01 PM
using Time class with
public int compareTo(Time t)
method.
if(this.getMeridians() != t.getMeridians())
return this.getMeridians().compareTo(t.getMeridians());
to sorted AM and PM, but I don't know how to sort hours and minutes. It's in 12-hour clock form, so 12:01 AM should be very first on the list. In order to do that, how should I fill up the compareTo(Time t)?
It should be like this.
12:01 AM
4:05 AM
5:04 AM
6:04 AM
12:01 PM
4:05 PM
5:04 PM
Dateobjectsuse collection.sort() to sort the collection