I have the following Array ():
{
"1 ":
{
"id":"12",
"usuarioA":"1",
"usuarioB":"2",
"mensaje":"Hola mi amor",
"date":"2017-01-19 03:02:12",
"TokenID":"1",
"remitente":"Andrey Homez",
"destinatario":"Paola Gonzales",
"CVX":"Paola Gonzales"
},
"2 ":
{
"id":"13",
"usuarioA":"1",
"usuarioB":"3",
"mensaje":"hey chaval",
"date":"2017-01-19 03:11:11",
"TokenID":"2",
"remitente":"Andrey Homez",
"destinatario":"Felipe Gomez",
"CVX":"Felipe Gomez"
},
"13 ":
{
"id":"11",
"usuarioA":"1",
"usuarioB":"1",
"mensaje":"Hablando conmigo mismo alv :"v",
"date":"2017-01-19 02:52:13",
"TokenID":"13",
"remitente":"Andrey Homez",
"destinatario":"Andrey Homez",
"CVX":"Andrey Homez"
}
}
How can I make sorted by the "date" index in descending ? In other words, it looks like this:
{
"2 ":
{
"id":"13",
"usuarioA":"1",
"usuarioB":"3",
"mensaje":"hey chaval",
"date":"2017-01-19 03:11:11",
"TokenID":"2",
"remitente":"Andrey Homez",
"destinatario":"Felipe Gomez",
"CVX":"Felipe Gomez"
},
"1 ":
{
"id":"12",
"usuarioA":"1",
"usuarioB":"2",
"mensaje":"Hola mi amor",
"date":"2017-01-19 03:02:12",
"TokenID":"1",
"remitente":"Andrey Homez",
"destinatario":"Paola Gonzales",
"CVX":"Paola Gonzales"
},
"13 ":
{
"id":"11",
"usuarioA":"1",
"usuarioB":"1",
"mensaje":"Hablando conmigo mismo alv :"v",
"date":"2017-01-19 02:52:13",
"TokenID":"13",
"remitente":"Andrey Homez",
"destinatario":"Andrey Homez",
"CVX":"Andrey Homez"
}
}
Something important is that the numbers 1
, 2
, 13
should be retained (I do not mean your order).
Thanks, in advance:)