I want to sort NSMutableArray which have NSInteger values inside. I tried to use this solution:
NSArray *sorted = [array sortedArrayUsingSelector:@selector(compare:)];
It almost worked, so i want to ask why not everything alright with it. Here is example of data:
not sorted = (
30,
42,
54,
6,
18
)
sorted = (
18,
30,
42,
54,
6
)
We can see that it sorted everything but 6 value which is at the end off array.
Why this could happened ?
Thank you.
Full method:
- (void) initialize{
NSInteger min = 30;
NSInteger interval = 12;
NSInteger count = floor(60/interval);
for (int i = 0; i < count; i++) {
[array addObject:[NSString stringWithFormat:@"%i",min]];
min +=interval;
if (min > 60)
min -= 60;
}
//DLog(@"not sorted = %@",minutes);
array = [[array sortedArrayUsingSelector:@selector(compare:)] mutableCopy];
//DLog(@"sorted = %@",minutes);
}