title: Sorting Array in Swift3
body: <p>In my code, I have a struct like the following:</p>
  
  <pre><code>struct Object {
      var name: String
      var count: Int
  </code></pre>
  
  <p>I am now creating an array of 10 Objects with random names and random counts.</p>
  
  <p>Is there an easy way to<br>
  a) sort them alphabetically<br>
  b) sort them numerically in ascending order</p>
  
  <p>Basically, there will be an array like so:
  <code>[Object1, Object2, Object3]</code>.
  Every Object has a <code>name</code> and <code>count</code> attribute, and I want the objects in that list be sorted via these two attributes.</p>
  
  <p>Solution in Swift2 (using this solution: <a href="https://stackoverflow.com/questions/37603960/swift-sort-array-of-objects-with-multiple-criteria">StackOverflow)</a>:</p>
  
  <pre><code>Object.sort{
          if $0.name != $1.name {
              return $0.name &lt; $1.name
          }
          else {
              //suits are the same
              return $0.count &lt; $1.count
          }
      }
  </code></pre>
  
  <p>However, this has been renamed to <code>sorted(by: )</code> in Swift3, and I don't quit get how to do that.</p>