Answers for "javascript sort map by value"

1

javascript sort map by value

var mapAsc = new Map([...map.entries()].sort((a,b) => a[0] > b[0]));
Posted by: Guest on December-23-2020
0

javascript sort map by value

var map = new Map();
map.set('2-1', "foo");
map.set('0-1', "bar");
map.set('3-1', "baz");

var mapAsc = new Map([...map.entries()].sort());

console.log(mapAsc)
Posted by: Guest on December-23-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language