sortPurchases method

List<PurchaseDetails> sortPurchases(
  1. List<PurchaseDetails> purchaseData
)

Implementation

List<PurchaseDetails> sortPurchases(List<PurchaseDetails> purchaseData) {
  List<PurchaseDetails> buffer = List.from(purchaseData);
  buffer.sort((a, b) {
    DateTime aDate = DateTime.fromMillisecondsSinceEpoch(
        int.parse(b.transactionDate ?? "0"));
    DateTime bDate = DateTime.fromMillisecondsSinceEpoch(
        int.parse(a.transactionDate ?? "0"));
    return aDate.compareTo(bDate);
  });
  return buffer;
}