Considering that I have the below response, which consists of date and time, I want them in sorted format. How can I sort the json of date time in descending format.
let data =
[
{
"created_at" : "2020-12-01T05:11:08Z",
"id" : "1"
},
{
"created_at" : "2022-10-10T06:18:08Z",
"id" : "2"
},
{
"created_at" : "2021-11-12T02:48:08Z",
"id" : "3"
},
,
{
"created_at" : "2021-11-12T02:49:08Z",
"id" : "4"
}
]
After applying the sorting code, I need the data should look like:
result =
[
{
"created_at" : "2022-10-10T06:18:08Z",
"id" : "2"
},
{
"created_at" : "2021-11-12T02:49:08Z",
"id" : "4"
},
{
"created_at" : "2021-11-12T02:48:08Z",
"id" : "3"
},
{
"created_at" : "2020-12-01T05:11:08Z",
"id" : "1"
}
]