Skip to content

Commit

Permalink
Sort classes by start and end period in timetable
Browse files Browse the repository at this point in the history
  • Loading branch information
vyPal committed Dec 26, 2023
1 parent 46bf6bd commit 046c032
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/timetable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,12 @@ TimeTableData processTimeTable(TimeTableData tt) {
}
}

classes.sort(
(a, b) => int.parse(a.startPeriod).compareTo(int.parse(b.startPeriod)));
classes.sort((a, b) {
int? sp = int.tryParse(a.startPeriod);
int? ep = int.tryParse(b.endPeriod);
if (sp == null || ep == null) return 0;
return sp.compareTo(ep);
});
periods.sort((a, b) => a.startTime.compareTo(b.startTime));

List<TimeTableClass> newClasses = [];
Expand Down

0 comments on commit 046c032

Please sign in to comment.