mapToListSortedByKey<T> static method

List<T> mapToListSortedByKey<T>(
  1. Map<int, T> map
)

Implementation

static List<T> mapToListSortedByKey<T>(Map<int, T> map) {
  // Get the keys of the map and sort them
  List<int> sortedKeys = map.keys.toList()..sort();

  // Create a list with values sorted by the sorted keys
  List<T> sortedList = sortedKeys.map((key) => map[key]!).toList();

  return sortedList;
}