Reputation: 12107
I have an NSArray, with objects ordered like so:
I would like to enumerate through this array in this order:
i.e. starting at some point that is not the beginning, but hitting all the items.
I imagine this is a matter of sorting first and then enumerating the array, but I'm not sure if that's the best technique... or, frankly, how to sort the array like this.
Adding details: These will be relatively small arrays, varying from 3 to 10 objects. No concurrent access. I'd like to permanently alter the sort order of the array each time I do this operation.
Upvotes: 0
Views: 340
Reputation: 185988
NSUInteger n = arr.count;
for (NSUInteger i = 0; i < n; ++i) {
id e = [arr objectAtIndex:(start + i)%n];
// ...
}
Upvotes: 1