From 862c02b3e7a686a9379d924cf39b67a0fd3f499b Mon Sep 17 00:00:00 2001 From: Mylloon Date: Mon, 1 Jan 2024 12:58:57 +0100 Subject: [PATCH] Sort days --- src/timetable.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/timetable.rs b/src/timetable.rs index bf992ed..5a6ae56 100644 --- a/src/timetable.rs +++ b/src/timetable.rs @@ -110,6 +110,14 @@ pub async fn timetable( } }); + // Sort by days + let day_positions = ["Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi"] + .iter() + .enumerate() + .map(|(i, &day)| (day.to_owned(), i)) + .collect::>(); + timetable.sort_by(|a, b| day_positions[&a.name].cmp(&day_positions[&b.name])); + (schedules, (semester as usize, timetable)) }