sort<T> method

void sort<T>(
  1. Comparable<T> getField(
    1. Dessert d
    ),
  2. bool ascending
)

Implementation

void sort<T>(Comparable<T> Function(Dessert d) getField, bool ascending) {
  desserts.sort((a, b) {
    final aValue = getField(a);
    final bValue = getField(b);
    return ascending
        ? Comparable.compare(aValue, bValue)
        : Comparable.compare(bValue, aValue);
  });
  notifyListeners();
}