【发布时间】:2018-04-21 01:57:55
【问题描述】:
我有 2 个数组:
Arr1 = [ ["name": "Player1", "userId": "11", "Score": 9, "picURL": "https://1111"], ["name": "Player2", "userId": "12", "Score": 6, "picURL": "https://2222"], ["name": "Player3", "userId": "13", "Score": 4, "picURL": "https://3333"], ["name": "Player4", "userId": "14", "Score": 8, "picURL": "https://4444"], ["name": "Player5", "userId": "15", "Score": 1, "picURL": "https://5555"] ]
Arr2 = [["userId": "12"], ["userId": "13"], ["userId": "15"]]
如何按“userId”映射此数组,以得到按“分数”按降序排序的数组,如下所示:
resultArr = [["name": "Player2", "Score": 6, "picURL": "https://2222], ["name": "Player3", "Score": 4, "picURL": "https://3333], ["name": "Player5", "Score": 1, "picURL": "https://5555] ]
【问题讨论】:
标签: arrays swift sorting mapping