I want to change the sequence of the keys of the object to the given one.(first male, then children followed by femal) There is an object:
const types = [
{female: 100, male: 200, children: 150},
{female: 100, male: 200, children: 150}
];
I get the object from the backend, where I need to change a sequence of the keys at the Front end of my app to male, children, female
.
I have never come across this problem, I tried several methods, didn't succeed. I will be extremely grateful for any help. Example output code for object fields:
{types && (
<ul>_.map(Object.keys(types), key => (
<li key={_.uniqueId(`${key}`)}>
<span>{key, types[key]}</span>
</li>
</ul>
)}
100 female
200 male
150 children
The conclusion looks like this. It is necessary to change to:
200 male
150 children
100 female
Thank you very much!