I’ve seen examples of something like
[someArray sortUsingSelector:@selector(compare:)];
I’m looking for an example that stores a collection of UIViews and I’d like to sort them in ascending or descending order based on tags I assume programatically when a new UIView is created.
If someone could provide a code example or instructions that would be fantastic
NSArray provides a number of methods to sort an array (all listed under the “Sorting” header in the NSArray docs). You can define a function, a method or a sort descriptor to compare the views based on their tags for sorting. For example, here’s an implementation using NSSortDescriptor: