deepSort method
Returns new instance of List, which is recursively sorted by values. It sorts by values nested List, Set or Map (primitive collections), nested primitive collections inside nested primitive collections and so on.
it gets rid of incomparable values like:
- bool
null
If there are more List, Set or Map, it groups them, sorts by length and puts in the following order:
Implementation
List<E> deepSort() {
var intDoubleValues = <dynamic>[...whereType<int>(), ...whereType<double>()]
..sort();
var stringValues = <String>[...whereType<String>()]..sort();
var lists = <List>[
for (var list in whereType<List>()) ...{
list.deepSort(),
}
]..sort(_sortByLengthRecipe);
var sets = <Set>[
for (var set in whereType<Set>()) ...{
set.deepSort(),
}
]..sort(_sortByLengthRecipe);
var maps = <Map>[
for (var map in whereType<Map>()) ...{
map.deepSortByValue(),
}
]..sort(_sortByLengthRecipe);
return <E>[
...intDoubleValues.cast<E>(),
...stringValues.cast<E>(),
...lists.cast<E>(),
...sets.cast<E>(),
...maps.cast<E>(),
];
}