i am trying to do a mutable array sort, it is crashing, (or may be i guess it is going on loop), what is wrong ?
Code:
int count = [self.objArray count] ;
for (int i = 0; i < count; i++) {
for (int j = 0; j < count; j++) {
if ([self averageConsumption:[self.objArray objectAtIndex:i]] > [self averageConsumption:[self.objArray objectAtIndex:j]]) {
NSMutableArray *arr = [self.objArray objectAtIndex:i];
[self.objArray replaceObjectAtIndex:i withObject:[self.objArray objectAtIndex:j]];
[self.objArray replaceObjectAtIndex:j withObject:arr];
}
}
}