sort method

Map<K, V> sort(
  1. int compare(
    1. MapEntry<K, V>,
    2. MapEntry<K, V>
    )
)

Sorts the Map based on the given function and RETURNS the sorted map. (Doesn't sort in place!)

Implementation

Map<K, V> sort(int Function(MapEntry<K, V>, MapEntry<K, V>) compare){
  List<MapEntry<K, V>> mapAsList = entries.toList();
  mapAsList.sort(compare);
  return LinkedHashMap.fromEntries(mapAsList);
}