sort method
Sorts the map based on the provided comparison function.
Implementation
void sort(int Function(V a, V b) compare) {
List<OrderedMapIndexedValue<K, V>> indexedCopy = [];
for (int i = 0; i < values.length; i++) {
indexedCopy.add(OrderedMapIndexedValue(keys[i], values[i], i));
}
indexedCopy.sort((a, b) {
return compare(a.value, b.value);
});
clear();
for (int i = 0; i < indexedCopy.length; i++) {
add(indexedCopy[i].key, indexedCopy[i].value);
}
}