【发布时间】:2020-06-29 20:49:01
【问题描述】:
我有以下两个数组:
fetchedProducts = [
[name: "productName20", id: 20],
[name: "productName3", id: 3],
[name: "productName1", id: 1]
]
sortedProducts = [
[productName1: "1"], // I know the numbers here are string; I need them to be string
[productName20: "20"],
[productName3: "3"]
]
现在我需要根据sortedProducts 的顺序对fetchedProducts 进行排序,所以它最终会如下所示:
fetchedProducts = [
[name: "productName1", id: 1],
[name: "productName20", id: 20],
[name: "productName3", id: 3]
]
【问题讨论】:
-
这已经被问过/回答过很多次了。这能解决您的问题吗? stackoverflow.com/q/43056807/3141234
标签: arrays swift sorting arraylist