iOS数组排序
2018-11-19 本文已影响0人
浪呀么浪打浪
//初始的array
NSArray * array = @[@"童谣",@"收藏",@"电吉他",@"新玩法",@"英文",@"民谣",@"经典",@"抖音",@"尤克里里",@"流行",@"摇滚",@"架子鼓",@"KTV"];
//排序的array
NSArray *finaArray= @[@"新玩法",@"经典",@"抖音",@"童谣",@"收藏",@"电吉他",@"尤克里里",@"架子鼓",@"KTV",@"流行",@"摇滚",@"英文",@"民谣"];
NSArray*dataArray = [arraysortedArrayUsingComparator:^NSComparisonResult(id _Nonnullobj1,id _Nonnullobj2) {
NSString* info1=obj1;
NSString* info2=obj2;
return[finaArrayindexOfObject:info1]>[finaArrayindexOfObject:info2];
}];