sortDateList static method

List<String> sortDateList({
  1. required List<String> dates,
})

it will sort the dates

Implementation

static List<String> sortDateList({required List<String> dates}) {
  List<DateTime> tempList = [];
  DateFormat format = DateFormat("dd/MM/yyyy");
  for (int i = 0; i < dates.length; i++) {
    tempList.add(format.parse(dates[i]));
  }
  tempList.sort((a, b) => a.compareTo(b));
  dates.clear();
  for (int i = 0; i < tempList.length; i++) {
    dates.add(format.format(tempList[i]));
  }
  return dates;
}