title: How do I sort a list of records by multiple fields?
body: <p>I want to sort a List of coordinates first by its x coordinates and and then by its y coordinates:</p>
  
  <pre><code>Orginal: (7,8)(10,22)(7,3)(5,10)(20,14)(7,10)(7,3)
  
  First Step by x: (5,10)(7,8)(7,3)(7,10)(7,3)(10,22)(20,14)
  
  Second Step by y: (5,10)(7,3)(7,3)(7,8)(7,10)(10,22)(20,14)
  </code></pre>
  
  <p>I have already a functions that works for the first step:</p>
  
  <pre><code>function SortCoords(Item1: Pointer; Item2: Pointer): Integer;
  var
  line1 : Coords;
  line2 : Coords;
  begin
    line1 :=  Coords;(Item1);
    line2 :=  Coords;(Item2);
  
    if (line1.X &lt; line2.X) then 
      result := -1
    else if (line1.X &gt; line2.X) then 
       result := 1
    else
       result := 0;
  
  end; 
  </code></pre>
  
  <p>But i dont get the second step.</p>