How to sort an array of objects in Swift : <p>I have the following Java code below that I am trying to convert to Swift. I would really appreciate if somebody can help me on this issue.</p>

<p>Thanks</p>

<pre><code>private static class CarComparator implements Comparator&lt;Car&gt;{

     public int compare(Car o1, Car o2)
      {
     return o1.name.compareTo(o2.name);
      }

}


 List&lt;Car&gt; cars = new ArrayList&lt;Car&gt;();

 Collections.sort(cars, new CarComparator());
</code></pre>
