title: Javascript - Array of objects group by year, month and date
body: <p>I'm trying to sort an array of object by date month and week</p>
  
  <pre><code>myArray : [
              {'name' : 'example1', 'date' : '2011-01-01'},
              {'name' : 'example1', 'date' : '2011-01-02'},
              {'name' : 'example1', 'date' : '2011-02-02'},
              {'name' : 'example1', 'date' : '2011-02-15'},
              {'name' : 'example1', 'date' : '2011-02-17'},
              {'name' : 'example1', 'date' : '2012-01-01'},
              {'name' : 'example1', 'date' : '2012-03-03'},
  ]
  </code></pre>
  
  <p>I would like to have such a result :</p>
  
  <pre><code>result : [{
                      '2011': { // Year 2011
                          '01': { // January
                              '01' : [ // First week of January
                                  {'name' : 'example1', 'date' : '2011-01-01'},
                                  {'name' : 'example1', 'date' : '2011-01-02'},
                              ]
                          },
                          '02' : { // February
                              '01' : [ // First week of February
                                  {'name' : 'example1', 'date' : '2011-02-02'},
                              ],
                              '03' : [
                                  {'name' : 'example1', 'date' : '2011-02-15'},
                                  {'name' : 'example1', 'date' : '2011-02-17'},
                              ]
                          }
                      },
                      '2012' : { // Year 2012
                          '01' : { // January
                              '01': [ // First week of January
                                  {'name': 'example1', 'date': '2012-01-01'}
                              ]
                          },
                          '03': { // March
                              '01' : [ // First week of March
                                  {'name' : 'example1', 'date' : '2012-03-03'},
                              ]
                          }
                      }
                  }]
  </code></pre>
  
  <p>I use <code>lodash.groupBy</code> with <code>return getISOWeek(obj.date)</code> or <code>return getMonth(obj.date)</code> or <code>return getYear(obj.date)</code>.</p>
  
  <p>I managed to sort the data by year and month, year and week but I can't figure out how to do it for the three at the same time.</p>
  
  <p>Thanks for your help </p>