To sort JavaScript array by two numeric fields, we call the sort
method.
For instance, we write
const sorted = grouperArray.sort((a, b) => {
return a.size - b.size || a.glow - b.glow;
});
to call sort
with a callback that compares the items by their size
property values and glow
property values.