mdn sort map code example
Example 1: js map constructor
let myMap = new Map([
[1, 'one'], // [key, value]
[2, 'two'],
[3, 'three'],
]) // from MDN
Example 2: javascript sort
var names = ["Peter", "Emma", "Jack", "Mia", "Eric"];
names.sort(); // ["Emma", "Eric", "Jack", "Mia", "Peter"]
var objs = [
{name: "Peter", age: 35},
{name: "Emma", age: 21},
{name: "Jack", age: 53}
];
objs.sort(function(a, b) {
return a.age - b.age;
}); // Sort by age (lowest first)