I have an object of objects, which I'd like to sort by property... having some trouble wrapping my head around it:
sample = {
"Elem1": { title: "Developer", age: 33 },
"Elem2": { title: "Accountant", age: 24 },
"Elem3": { title: "Manager", age: 53 },
"Elem4": { title: "Intern", age: 18}
}
My expected result would be an object whose keys were now ordered Elem4, Elem2, Elem1, Elem3. Alternatively, I'd be fine with simply returning the keys in that order rather than physically sorting the object.
Is this more trouble than it's worth, or am I missing some obvious (or not-so-obvious) JavaScript-Fu that would make light work of something like this?
Thanks!
See Question&Answers more detail:os