2 回答
TA贡献1906条经验 获得超10个赞
您可以使用sort基于 Map 的条目。然后从排序的条目创建一个新的 MapSegmentlocaleCompare
var map=new Map();map.set("8014",{"Access to support":null,Capacity:1,"Comfort Level":null,"Control Level":1,"Growth Mindset":1.5405405405405403,Horizon:null,Motivation:null,"Open-Mindedness":null,Proactivity:null,Resiliency:null,Segment:"Level value 1"});map.set("8015",{"Access to support":null,Capacity:1,"Comfort Level":null,"Control Level":1,"Growth Mindset":1.5405405405405403,Horizon:null,Motivation:null,"Open-Mindedness":null,Proactivity:null,Resiliency:null,Segment:"Level value 2 or 5"});map.set("8016",{"Access to support":null,Capacity:1,"Comfort Level":null,"Control Level":1,"Growth Mindset":1.5405405405405403,Horizon:null,Motivation:null,"Open-Mindedness":null,Proactivity:null,Resiliency:null,Segment:"Level value 3 or 5"});
const sortedMap =
new Map(
Array.from(map)
.sort((a, b) => a[1].Segment.localeCompare(b[1].Segment))
);
console.log([...sortedMap.entries()])
添加回答
举报