为了账号安全,请及时绑定邮箱和手机立即绑定

萌新求教!JSON数据根据字段分组并排序

萌新求教!JSON数据根据字段分组并排序

繁花如伊 2019-10-31 09:37:21
[{"controlGroupId":0,"controlGroupName":"基础数据","controlSortId":0,"controlType":"CtlComboBoxEdit","domain":"CodeAirportAiracType"},{"controlGroupId":0,"controlGroupName":"基础数据","controlSortId":2,"controlType":"CtlComboBoxEdit","domain":"CodeAirportAiracType"},{"controlGroupId":2,"controlGroupName":"高级","controlSortId":6,"controlType":"CtlComboBoxEdit","domain":"CodeAirportAiracType"},{"controlGroupId":2,"controlGroupName":"高级","controlSortId":9,"controlType":"CtlComboBoxEdit","domain":"CodeAirportAiracType"}]这是例子真实情况controlGroupId可能有多个不确定的值。举例:controlGroupId为0的分为一组,为2的分为一组,取controlGroupName为组名,并且组之间升序。各组之中再根据controlSortId升序。这个例子期望的结果为[{title:"基础数据",group:[{controlGroupId:0,controlGroupName:"基础数据",controlSortId:0,controlType:"CtlComboBoxEdit",domain:"CodeAirportAiracType"},{controlGroupId:0,controlGroupName:"基础数据",controlSortId:2,controlType:"CtlComboBoxEdit",domain:"CodeAirportAiracType"}]},{title:"高级",group:[{controlGroupId:2,controlGroupName:"高级",controlSortId:6,controlType:"CtlComboBoxEdit",domain:"CodeAirportAiracType"},{controlGroupId:2,controlGroupName:"高级",controlSortId:9,controlType:"CtlComboBoxEdit",domain:"CodeAirportAiracType"}]}];
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 241 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信