Skip to content

Instantly share code, notes, and snippets.

@mkdynamic
Created December 15, 2011 04:52
Show Gist options
  • Save mkdynamic/1479884 to your computer and use it in GitHub Desktop.
Save mkdynamic/1479884 to your computer and use it in GitHub Desktop.
[selection sortedArrayUsingComparator:^(MKShape *a, MKShape *b) {
float leftEdgeA = NSMinX([a frame]);
float leftEdgeB = NSMinX([b frame]);
if (leftEdgeA < leftEdgeB) {
return (NSComparisonResult)NSOrderedAscending;
} else if (leftEdgeA > leftEdgeB) {
return (NSComparisonResult)NSOrderedDescending;
} else {
return (NSComparisonResult)NSOrderedSame;
}
}];
selection.sort_by { |shape| min_x(shape.frame) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment