Sorting an array in ascending order without losing the index Objective-C
- by thary
Hello all, I have an array for instance,
Array {
3.0 at Index 0
2.0 at Index 1
3.5 at Index 2
1.0 at Index 4
}
I would like to get sort it in ascending order without losing the index in the first place, like this,
Array {
1.0 at Index 4
2.0 at Index 1
3.0 at Index 0
3.5 at Index 2
}
When I sort the array using this,
NSArray *sortedArray = [hArray sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
[knnRecog sortUsingDescriptors:[NSArray arrayWithObject:sortAsc]];
I lose the index. Does anyone know a way to preserve the index after sorting the array? Thanks