Sander Swart
Sander Swart

Reputation: 271

sort ArrayList<ArrayList<String>> for 2nd entry of inner ArrayList

I'm writing an app which has a part where it displays calendar events. It currently reads the first five events of all the active calendars on the device and puts them in an ArrayList<ArrayList<String>> which I'll name calendarEvents for further notice. The entries of calendarEvents are <"Title", "Start time", "End time">. Those entries are sorted on start time per calendar. so

< entry 1 from calendar 1>
< entry 2 from calendar 1>
...
< entry 5 from calendar 1>
< entry 1 from calendar 2>

I want to sort those entries without respect to the calendar it came from. What is the best way to do that?

Upvotes: 0

Views: 237

Answers (1)

JRL
JRL

Reputation: 78003

Use Collections.sort(java.util.List, java.util.Comparator) and implement your Comparator class.

Upvotes: 2

Related Questions