Trying to sort/reorder following objects as from lowest and highest value
{ 'xlg': '10',
'lg': '9.6',
'md': '9',
'sm': '5',
'xsm': '3',
'xxsm': '2',
'xxxsm': '1.75',
'xxxxsm': '1'}
something like this :
{ 'xxxxsm': '1',
'xxxsm': '1.75',
'xxsm': '2',
'xsm': '3',
'sm': '5',
'md': '9',
'lg': '9.6',
'xlg': '10'}
and here is my input so far :
const sortObjectByValues = object => {
const sortedArray = Object.values(object).sort();
const sortedObject = sortedArray.reduce((acc, cur) => {
// No idea....
return acc;
}, {});
return sortedObject;
};
I am sure I can workout with reduce function. anyone could help me this out please ?
thanks