I currently have this object but I need to change the position of the keys.
const json = [
{
correo: "[email protected]",
enviado: true,
excel: true,
fechaSolicitud: "08-10-2021",
fechas: "[2021-07-31]",
idCliente: 34170,
pdf: true,
planes:
"[{f:25,p:110020904148}, {f:25,p:112690000002}, {f:25,p:112690000006}, {f:25,p:112690000007}, {f:25,p:112690000019}, {f:25,p:112690000025}, {f:25,p:112690000026}, {f:25,p:112690000030}, {f:25,p:112690000037}, {f:25,p:112690000038}, {f:25,p:112690000039}, {f:25,p:112690000040}, {f:25,p:112690000041}, {f:25,p:112690000042}, {f:25,p:112690000056}, {f:25,p:112690000057}, {f:25,p:112690000058}, {f:25,p:112690000059}, {f:25,p:112690000063}, {f:25,p:112690000069}, {f:25,p:112690000076}, {f:25,p:112690000083}, {f:25,p:112690000084}, {f:25,p:112690000104}, {f:25,p:112690000105}, {f:25,p:112690000108}, {f:25,p:112690000117}, {f:25,p:112690000130}, {f:25,p:112690000131}, {f:25,p:112690000132}]"
}
];
I am trying to sort the object by the keys and I need it like this
this is what it sends me when I iterate it
correo
enviado
excel
fechaSolicitud
fechas
idCliente
pdf
planes
I need to achieve this result
fechaSolicitud
idCliente
correo
enviado
pdf
excel
fechas
planes
I show you the code I’ve been trying out
let columnsArray: any[];
for (const key in json) {
if (json.hasOwnProperty(key)) {
columnsArray = Object.keys(json[key])
columnsArray.sort()
}
}
here is the codesanbox if someone wants to help me enter link description here