title: Swift: Sort array of objects alphabetically
body: <p>I have this:</p>
  
  <pre><code>class Movies {
    Name:String
    Date:Int
  }
  </code></pre>
  
  <p>and an array of [Movies]. How do I sort the array alphabetically by name? I've tried:</p>
  
  <p><code>movieArr = movieArr.sorted{ $0 &lt; $1 }</code></p>
  
  <p>and </p>
  
  <p><code>movieArr = sorted(movieArr)</code></p>
  
  <p>but that doesn't work because I'm not accessing the name attribute of Movies.</p>