Student *s1 = [Student new];
s1.city = @"Delhi";
Student *s2 = [Student new];
s2.city = @"Mumbai";
NSArray *arrModels = @[s1,s2];
NSArray *arrCompareModel = @[@"Mumbai",@"Delhi"];
我需要根据on arrCompareModel
对arrModels
进行排序。基于比较模型对阵列进行排序iOS
web中的所有解决方案均与升序相关。但在这里我有一个自定义模型。 我该如何实现它?
使用'sortedArrayUsingComparator:',你可以检查http://stackoverflow.com/questions/38768463/sort-nsarray-custom-objects-by-another-nsarray-custom-objects/38769228#38769228与'indexforItem:inList:'可能只是'[arrCompareModel indexOfObject:student1Or2AccordingToTheCase.city];' – Larme
检查我的答案 –