var sortMap = function(map, isKeyUpSort) {
let keys = new Array()
for (var key of map.keys()) {
keys.push(key)
}
if (isKeyUpSort) {
keys.sort(function(key1, key2) {
return key1 - key2
})
} else {
keys.sort(function(key1, key2) {
return key2 - key1
})
}
let newMap = new Map()
keys.forEach(key => {
newMap.set(key, map.get(key))
})
return newMap
}