我有一个Map<String,dynamic>,我从一个json响应中得到,如下所示。
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"
}
]
};
字符串
我想按“paymentDueDate”排序。这看起来像一个列表的Map。有人可以帮助我如何实现这个排序在扑?下面是我尝试过的,但没有效果。
map["payments"].sort(
(a, b) => (
a[DateTime.tryParse('paymentDueDate')].compareTo(
b[DateTime.tryParse('paymentDueDate')],
),
),
);
型
2条答案
按热度按时间yzckvree1#
可能是这样的
字符串
alen0pnh2#
试试这样做:
字符串