Skip to content

Instantly share code, notes, and snippets.

@wisaruthk
Last active August 29, 2015 14:06
Show Gist options
  • Save wisaruthk/0f01dfe49ecefe9c4863 to your computer and use it in GitHub Desktop.
Save wisaruthk/0f01dfe49ecefe9c4863 to your computer and use it in GitHub Desktop.
Sorted object in NSMutableArray
NSMutableArray *items = [self initialItems];
[items sortUsingComparator:^NSComparisonResult(id obj1, id obj2) {
Item *i1 = obj1;
Item *i2 = obj2;
if (i1.code > i2.code) {
return (NSComparisonResult)NSOrderedDescending;
}
if (i1.code < i2.code) {
return (NSComparisonResult)NSOrderedAscending;
}
return (NSComparisonResult)NSOrderedSame;
}
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment