distinctBy<K> method
Returns a list containing only elements from the given collection
Implementation
// having distinct keys returned by the given [selector] function.
//
// The elements in the resulting list are in the same order as they were in the source collection.
List<T> distinctBy<K>(K block(T obj)) {
if (this == null) return <T>[];
var set = HashSet<K>();
var list = <T>[];
for (var e in this!) {
var key = block(e);
if (set.add(key)) {
list.add(e);
}
}
return list;
}