sort method

void sort(
  1. int compare(
    1. MapEntry<K, V> a,
    2. MapEntry<K, V> b
    )
)

Sorts a LinkedHashMap according to a specified Comparator on MapEntrys.

Note that since extension methods are syntactic sugar that depend on static (not runtime) types, this extension method requires that the receiver be declared as (or casted to) a LinkedHashMap and not as a general Map.

Implementation

void sort(int Function(MapEntry<K, V> a, MapEntry<K, V> b) compare) {
  var entries = this.entries.toList()..sort(compare);
  clear();
  addEntries(entries);
}