sortedByTime method
Implementation
List<T> sortedByTime(Comparable key(T e), {bool reversed = false}) {
// Sort with a custom comparison to handle "Anytime" items first
List<T> sortedList = List<T>.from(this)
..sort((a, b) {
final valueA = key(a);
final valueB = key(b);
// Check if either value is "Anytime", push those to the top
if (valueA == 'Anytime') return 1;
if (valueB == 'Anytime') return -1;
// Otherwise, compare normally
return valueA.compareTo(valueB);
});
// Reverse if needed
return reversed ? sortedList.reversed.toList() : sortedList;
}