Created
November 17, 2016 08:16
-
-
Save amyhametov/6b64419cb9083b782f00bf71f40dcab0 to your computer and use it in GitHub Desktop.
Sorting and filtering duplications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSArray<NSNumber *> *)sortArray:(NSArray<NSNumber *> *)array { | |
NSArray<NSNumber *> *sortedArray = [array sortedArrayUsingComparator:^NSComparisonResult(NSNumber *num1, NSNumber *num2) { | |
return [num1 compare:num2]; | |
}]; | |
NSOrderedSet *orderedSet = [NSOrderedSet orderedSetWithArray:sortedArray]; | |
NSArray *arrayWithoutDuplicates = orderedSet.array; | |
return arrayWithoutDuplicates; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment