I have a Map<String, dynamic> i get from a json response as below.
map = {
"status": "Success",
"payments": [
{
"id": 99,
"groupID": 19,
"paymentDueDate": "2023-05-12",
"paymentDate": null,
"userID": 13,
"amount": 500,
"forDuration": "May",
"proofOfPayment": null,
"paymentMode": null,
"paymentID": null,
"paymentToken": null,
"approvedBy": null,
"approvedAt": null,
"status": "pending",
"note": "",
"created_at": "2023-05-09T03:39:01.000000Z",
"updated_at": "2023-05-09T03:39:01.000000Z"
}
]
};
I will like to sort by "paymentDueDate". This looks like a map of lists. Can someone help me on how i can achieve this sorting in flutter? below is what i have tried but it is not working.
map["payments"].sort(
(a, b) => (
a[DateTime.tryParse('paymentDueDate')].compareTo(
b[DateTime.tryParse('paymentDueDate')],
),
),
);
2
Answers
May be something like this
I think you are asking for something like this.