I have a Core Data object called Line. Each row contains an instance of VerticePoint that contains the x and y properties. These x and y vertices form simple two-dimensional polygons.
What I want to do is sort the array of these Line objects, which is in random order, so that the beginning of the form, the bottom left point, is always the first element in the array, and then the rest of the wounds are counterclockwise from the origin.
So say the points in my original array (the xy axis is centered at 0,0):
x = 20, y = 20
x = 20 , y= 10
x = 10, y=10
x = 10, y =20
x = 15, y = 10
I want to sort them like this:
x = 10, y=10
x = 15, y = 10
x = 20 , y= 10
x = 20, y = 20
x = 10, y =20
Many thanks
source
share