iOS - Sort mutable array of views by each frame
NSComparator comparatorBlock = ^(UIView *obj1, UIView *obj2) {
if (obj1.frame.origin.y > obj2.frame.origin.y) {
return (NSComparisonResult)NSOrderedDescending;
}
if (obj1.frame.origin.y < obj2.frame.origin.y) {
return (NSComparisonResult)NSOrderedAscending;
}
return (NSComparisonResult)NSOrderedSame;
};
[array sortUsingComparator:comparatorBlock];
Written by Noval Agung Prayogo
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Objective-c
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#