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)

You can pass a comparison function to List.sort.

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

And if you want to reverse sort:

b.someProperty.compareTo(a.someProperty)

Or sort it and then use .reversed

--

--

Flutter Developer
Flutter Developer

Written by Flutter Developer

Flutter and Native Android developer

No responses yet