sortBy static method
The sortBy method sorts the list of objects by the given key.
Example:
sortBy(list, "price") // create new list with soreted list according to price
Implementation
static List<dynamic> sortBy(List<dynamic> list, String key,
[bool isDesc = false]) {
list.sort((dynamic a, dynamic b) => a[key].compareTo(b[key]));
return isDesc ? list.reversed.toList() : list;
}