/* For sorting the entries as per the -o flag. * This allows a list of entries to be sorted, * e.g. title-alphabetic, date-reverse, date-forward. */ enum SortMode { /* For instance: * TitleAA, TitleZZ, TitleFF * becomes * TitleAA, TitleFF, TitleZZ */ TitleAlphabetic; /* For instance: * 2023-10-01, 2023-10-05, 2023-10-03 * becomes * 2023-10-05, 2023-10-03, 2023-10-01 */ DateReverse; /* For instance: * 2023-10-01, 2023-10-05, 2023-10-03 * becomes * 2023-10-01, 2023-10-03, 2023-10-05 */ DateForwards; } // TODO: write sorting functions. Entry[] sort_title_alphabetic(Entry[] entries) { return entries; } Entry[] sort_date_reverse(Entry[] entries) { return entries; } Entry[] sort_date_forward(Entry[] entries) { return entries; } Entry[] sort(Entry[] entries, SortMode sort_mode) { switch (sort_mode) { case SortMode.TitleAlphabetic: return sort_title_alphabetic(entries); case SortMode.DateReverse: return sort_date_reverse(entries); case SortMode.DateForward: return sort_date_forward(entries); } }