I have the following Map:
Map<String, dynamic> data = {'two': {'date' : 2}, 'zero': {'date' : 1}, 'three': {'date' : 3}, 'one': {'date' : 2},};
I'd like to order it by date.
I'm trying this code:
final sorted = SplayTreeMap<String,dynamic>.from(data, (a, b) => data[a]["date"].compareTo(data[b]["date"]));
with output:
{'two': {'date' : 2}, 'zero': {'date' : 1}, 'three': {'date' : 3}}
How could I avoid deletion of duplicate value ('date': 2 appeared two times but now in sorted appears only once)?