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

Nomnom picture Nomnom · Nov 29, 2018 · Viewed 108.8k times · 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

Nate Bosch picture Nate Bosch · Nov 30, 2018

You can pass a comparison function to List.sort.

someObjects.sort((a, b) => a.someProperty.compareTo(b.someProperty));