我有一个由字典填充的数组,我需要按照其中一个键的值的字母顺序对该数组进行排序。
这是我的数组:
这是我的数组:
tu dictus: (
{
brand = Ryul;
productTitle = Any;
quantity = 1;
subBrand = "Ryul INJ";
type = Product;
},
{
brand = Trol;
productTitle = Different;
quantity = 2;
subBrand = "";
type = Brand;
},
{
brand = Dtor;
productTitle = Any;
quantity = 1;
subBrand = "";
type = Product;
},
{
brand = Ryul;
productTitle = Different;
quantity = 2;
subBrand = "Ryul CHES";
type = SubBrand;
},
{
brand = Anan;
productTitle = Any;
quantity = 1;
subBrand = "";
type = Product;
}
)
通常我会使用以下方法对数组进行排序:
myArray = [uniqueProdsArray sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
如何使用字典的brand
键进行排序?
Schwartzian Transform
。我已经为此制作了一个Swift包:https://github.com/neoneye/SwiftySchwartzianTransform - neoneye