Ios Swift:使用字典对数组进行排序

Ios Swift:使用字典对数组进行排序,ios,arrays,swift,dictionary,Ios,Arrays,Swift,Dictionary,我有这个阵列: [[Lots: 2783, Development: Suntec City], [Lots: 1583, Development: Marina Square], [Lots: 594, Development: The Esplanade], [Lots: 1270, Development: Millenia Singapore], [Lots: 283, Development: Singapore Flyer], [Lots: 185, Development: Orc

我有这个阵列:

[[Lots: 2783, Development: Suntec City], [Lots: 1583, Development: Marina Square], [Lots: 594, Development: The Esplanade], [Lots: 1270, Development: Millenia Singapore], [Lots: 283, Development: Singapore Flyer], [Lots: 185, Development: Orchard Point], [Lots: 152, Development: The Heeren], [Lots: 595, Development: Plaza Singapura], [Lots: 77, Development: The Cathay], [Lots: 302, Development: Mandarin Hotel], [Lots: 1092, Development: Ngee Ann City], [Lots: 331, Development: Wisma Atria], [Lots: 1251, Development: VivoCity P3], [Lots: 933, Development: Sentosa], [Lots: 369, Development: Tang Plaza], [Lots: 932, Development: Harbourfront Centre], [Lots: 196, Development: Far East Plaza], [Lots: 324, Development: Centrepoint], [Lots: 218, Development: Concorde Hotel], [Lots: 434, Development: ION Orchard], [Lots: 194, Development: 313@Somerset], [Lots: 1971, Development: Resorts World Sentosa], [Lots: 726, Development: VivoCity P2], [Lots: 268, Development: Orchard Central], [Lots: 386, Development: Park Mall], [Lots: 812, Development: Marina Bay Sands]]
我想按字母顺序按“开发”值对它们进行分类。我尝试过使用sorted by,它似乎只适用于字典这应该可以帮助您:

array.sort({ $0.Development > $1.Development })


这是比较第一个参数和第二个参数的闭包的缩写。(假设两者都是字符串。)(您。)

请显示您尝试过的实际代码。给我们一些开始的东西。我有一个错误,无法使用类型为“(,)->”@Eneres的参数列表调用“sort”,我刚刚遇到了相同的问题,但是使用
fliter
。我还在寻找解决办法。如果我找到了,我会和你分享的。@Eneres请看。答案也会解决你的问题。对不起,我是新来的斯威夫特。不确定如何将其应用于我的阵列:(
DataArray.sort {
                item1, item2 in
                let development1 = item1["Development"]! as String
                let development2 = item2["Development"]! as String
                return development1 > development2
            }