groupSort<T, K> function
Groups the specified iterable of elements according to the specified key
function, sorts the groups according to the specified valueComparator for
values and keyComparator for keys, and then returns a list of keys in
sorted order.
If the comparison of values results in a tie (i.e., comparison returns 0),
the keyComparator is used to break the tie and determine the order of the
keys. If valueComparator is not provided, it defaults to ascending, and
if keyComparator is not provided, it also defaults to ascending.
Implementation
List<K> groupSort<T, K>(Iterable<T> iterable, K Function(T) key,
[num Function(List<T>, List<T>) valueComparator = ascending,
num Function(K, K) keyComparator = ascending]) {
return sort(group(iterable, key).entries, (g1, g2) {
var comp = valueComparator(g1.value, g2.value);
return comp != 0 ? comp : keyComparator(g1.key, g2.key);
}).map((e) => e.key).toList();
}