Sort a list of objects in Flutter (Dart) by property value

Question

Asked by Nomnom on November 29, 2018 (source).

How to sort a list of objects by the alphabetical order of one of its properties (Not the name but the actual value the property holds)?

Answer

Question answered by Nate B (source).

You can pass a comparison function to List.sort.

someObjects.sort((a, b) => a.someProperty.compareTo(b.someProperty));
DART FLUTTER
SHARE: