I have an array of objects with two properties: Name and Hours.
For instance:
array = [ {name: "ANDY", hours: 40 }, {name: "ANDY", hours: 50 }, {name: "GREG", hours: 40 }, ]
For example, in my array, I would like the sorting result to have Andy with the most hours at the beginning, then Andy with a little less hours, and then Greg, because his name comes later in alphabetical order, etc. etc.
Since the array.sort () function passes two array elements for comparison, I understand that this is not a way to go for me, but not come up with an elegant solution. Please help me.
source share