title: Group and sort an array in Swift
body: <p>Let's say that I have this code:</p>
  
  <pre><code>class Stat {
     var statEvents : [StatEvents] = []
  }
  
  struct StatEvents {
     var name: String
     var date: String
     var hours: Int
  }
  
  var currentStat = Stat()
  
  currentStat.statEvents = [
     StatEvents(name: "lunch", date: "01-01-2015", hours: 1),
     StatEvents(name: "dinner", date: "02-01-2015", hours: 2),
     StatEvents(name: "dinner", date: "03-01-2015", hours: 3),
     StatEvents(name: "lunch", date: "04-01-2015", hours: 4),
     StatEvents(name: "dinner", date: "05-01-2015", hours: 5),
     StatEvents(name: "breakfast", date: "06-01-2015", hours: 6),
     StatEvents(name: "lunch", date: "07-01-2015", hours: 7),
     StatEvents(name: "breakfast", date: "08-01-2015", hours: 8)
  ]
  </code></pre>
  
  <p>I would like to know if there's a way to get an array with an output like this:</p>
  
  <pre><code>- [0]
    - name : "lunch"
    - date
      - [0] : "01-01-2015"
      - [1] : "04-01-2015"
      - [2] : "07-01-2015"
    - hours
      - [0] : 1
      - [1] : 4
      - [2] : 7     
  - [1]
    - name : "dinner"
    - date
      - [0] : "02-01-2015"
      - [1] : "03-01-2015"
      - [2] : "05-01-2015"
    - hours
      - [0] : 2
      - [1] : 3   
      - [2] : 5          
  - [2]
    - name : "breakfast"
    - date
      - [0] : "06-01-2015"
      - [1] : "08-01-2015"
    - hours
      - [0] : 6
      - [1] : 8 
  </code></pre>
  
  <p>As you can see, the final array should be grouped by "name" descendant.
  @oisdk can you please check this out??</p>