I have an object object that I would like to sort by property ... with some problems wrapping around itself:
sample = {
"Elem1": { title: "Developer", age: 33 },
"Elem2": { title: "Accountant", age: 24 },
"Elem3": { title: "Manager", age: 53 },
"Elem4": { title: "Intern", age: 18}
}
My expected result will be an object whose keys have now been ordered by Elem4, Elem2, Elem1, Elem3. Alternatively, everything will be fine, just returning the keys in that order, rather than physically sorting the object.
Is this more of a problem than it's worth, or did I miss some obvious (or not so obvious) JavaScript-Fu that would make it easier to work on something like this?
Thank!
source
share