products.sort((a,b) {
return a.compareTo(b);
});
products.sort((a,b) => a.compareTo(b));
import 'package:intl/intl.dart';
void main() {
List products = [
"2019-11-25 00:00:00.000",
"2019-11-22 00:00:00.000",
"2019-11-22 00:00:00.000",
"2019-11-24 00:00:00.000",
"2019-11-23 00:00:00.000"
];
List<DateTime> newProducts = [];
DateFormat format = DateFormat("yyyy-MM-dd");
for (int i = 0; i < 5; i++) {
newProducts.add(format.parse(products[i]));
}
newProducts.sort((a,b) => a.compareTo(b));
for (int i = 0; i < 5; i++) {
print(newProducts[i]);
}
}