我想知道如何在Swift中对多维数组使用sort
或sorted
函数。
例如,有一个数组:
[
[5, "test888"],
[3, "test663"],
[2, "test443"],
[1, "test123"]
]
我希望你能够通过第一个ID从低到高对其进行排序:
[
[1, "test123"],
[2, "test443"],
[3, "test663"],
[5, "test888"]
]
那么我们该如何做呢?谢谢!
sort
是可变方法,而sorted
是返回一个新数组的方法... - Eric Aya