按字母顺序对对象的多维数组进行分组

时间:2019-03-12 15:53:11

标签: sorting swift4.2

如何通过名称的首字母构建nsobject数组和SORT数组

var obj1 = Model(name:"Anne", lastName: "Loren");
var obj2 = Model(name:"Antoinne", lastName: "Grace");
var obj3 = Model(name:"Lourdes", lastName: "Moore");
var obj4 = Model(name:"Nick", lastName: "Lord");
var array = [obj1, obj2, obj3, obj4];
var data = [[Model]]();
data = [[obj1, obj2], [obj3], [obj4]];

obj1和obj2的首字母相同

0 个答案:

没有答案