with an object like
{
5: ['C','A','B'],
8: ['E','F','D']
}
I'm trying to sort the arrays of each key, while returning the entire object. The above would come back looking like this:
{
5: ['A','B','C'],
8: ['D','E','F']
}
I've tried lots of variations of
Object.keys(myObj).map(k => {
return { k: myObj[k].sort() };
}
But this puts a literal k as each key instead of maintaining the keys from the original object. Not to mention this also creates an array of objects since map is returning an object for each key.
Edit:
I've found lots of "sort array of objects" - but not a "sort object of arrays" on SO - dupe and link if it already exists please.
return { [k]: myObj[k].sort() };kissue. However the result of themapabove is an array of objects, instead of an object of arrays (I realize that's howmapworks)