(Please excuse any errors - this is my first post and I am also relatively new to Javascript)
I'm trying to sort an array of objects by a specific property value in Javascript. I have several objects as follows:
var Obj1 = {firstName: "John", lastName: "Doe", age: 46};
var Obj2 = {firstName: "Paul", lastName: "Smith", age: 22};
var Obj3 = {firstName: "Trent", lastName: "Johnson", age: 81};
And I have saved these into an array for easy access:
var Arr = [Obj1, Obj2, Obj3];
I wish to sort these objects within the array by age, giving:
Arr = [Obj2, Obj1, Obj3];
whilst still keeping the integrity of each object (ie. Obj1 still contains John, Doe and 46).
From my research I haven't seen anyone address this situation in a simple manner.
Thank you for any direction you might be able to give me!