{
a: [
{ value: 132, lable: 4, type: 'a'},
{ value: 532, lable: 1, type: 'a'},
{ value: 2462, lable: 9, type: 'a'},
],
b: [
{ value: 132, lable: 24, type: 'b'},
{ value: 432, lable: 13, type: 'b'},
{ value: 1812, lable: 5, type: 'b'},
]
c: [
{ value: 1932, lable: 8, type: 'c'}
]
}
function dealArr(arr) { const res = {}; for (let obj of arr) { if (!res[obj["type"]]) { res[obj["type"]] = [obj]; } else { res[obj["type"]].push(obj); } } for (let key in res) { res[key].sort((a, b) => a.value - b.value); } return res; }
function getSearchParams(url) { const arr = url.split("?")[1].split("&"); const res = {}; for (let item of arr) { let help = item.split("="); const [key, val] = help; let temp = decodeURI(val).replace(/%3A/g, ":").replace(/%2C/, ","); try { temp = JSON.parse(temp); } catch (e) {} res[key] = temp; } return JSON.stringify(res); }