title: Identify the top left, top right, bottom left and bottom right position of a rectangle in Swift (elegant solution)
body: <p>I'd like to find an elegant solution to identify the corners of a rectangle given a list of points (that I'm sure will define a rectangle). </p>
  
  <p>Let's say we have this array of <code>CGPoint</code>: </p>
  
  <pre><code>var points:[CGPoint] = []
  points.append(CGPoint(x:1, y:0)) //TL
  points.append(CGPoint(x:3, y:0)) //TR
  points.append(CGPoint(x:1, y:2)) //BL
  points.append(CGPoint(x:3, y:2)) //BR
  </code></pre>
  
  <p>Which would be an elegant solution to understand that TopLeft corner is at index 0, Top Right at index 1... and so on? </p>
  
  <p>I could cycle through the array multiple times and find it using a comparison... can you think at a better solution maybe using <code>sort</code> or <code>filter</code> ? </p>
  
  <p>EDIT: Please note that the points array is unordered. I don't have a precise sequence of points. </p>