private void sortEvents ( List < ? extends WeekViewEvent > events ) { Collections . sort ( events , new Comparator < WeekViewEvent > ( ) { @ Override public int compare ( WeekViewEvent event1 , WeekViewEvent event2 ) { long start1 = event1 . getStartTime ( ) . getTimeInMillis ( ) ; long start2 = event2 . getStartTime ( ) . getTimeInMillis ( ) ; int comparator = start1 > start2 ? 1 : ( start1 < start2 ? - 1 : 0 ) ; if ( comparator == 0 ) { long end1 = event1 . getEndTime ( ) . getTimeInMillis ( ) ; long end2 = event2 . getEndTime ( ) . getTimeInMillis ( ) ; comparator = end1 > end2 ? 1 : ( end1 < end2 ? - 1 : 0 ) ; } return comparator ; } } ) ; }
Sorts the events in ascending order .