title: Collect json disordered, order it and show it in chart.js
body: <p>I'm calling a currency exchange api that returns a json disordered with 2 arrays and I need to get the date in a variable and the corresponding value in another variable to be able to show the data posteriormentes in a graph with chart.js.</p>
  
  <p>The JSON I receive is the following:</p>
  
  <pre><code>{"rates": {
          "2018-05-04": {"USD": 1.1969},
          "2018-08-27": {"USD": 1.1633},
          "2018-06-08": {"USD": 1.1754},
          "2018-08-22": {"USD": 1.1616},
          "2018-07-19": {"USD": 1.1588}
            }
  }
  </code></pre>
  
  <p>I make the call by ajax with the following code:</p>
  
  <pre><code>$.ajax({
     url: '(WEBSITE)', // Skipped to avoid spamming
     type: 'GET',
     dataType: 'json',
     data: {},
     success: function (data) {         
        var ctx = document.getElementById('myChart').getContext('2d');
  
        // I take the JSON to see the dates
        var var2 = data.rates;
        var fecha = Object.keys(var2);
        var fecha = fecha;
        console.log( fecha ); // Output ["2018-05-04", "2018-08-27", "2018-06-08", "2018-08-22", "2018-07-19"]
  
         // CHART
          var chart = new Chart(ctx, {
         // The type of chart we want to create
          type: 'line',
            // The data for our dataset
             data: {
               labels: fecha,
               datasets: [{
                 label: 'Prueba chart',
                 backgroundColor: 'rgb(125, 255, 238)',
                 borderColor: 'rgb(59, 255, 229)',
                 data: valores
               }]
              },
              // Configuration options go here
               options: {}
            });
         },
        error: function (error) { console.log(error); }
      });   
  </code></pre>
  
  <p>However if I try to take the values of each coin using a "for in" loop it shows me the following result:</p>
  
  <pre><code>for (fecha in var2) {
   console.log( [var2[fecha].USD] );
   var valores = [var2[fecha].USD];
  }
  // Output a record for each row, not an array:
  [1.1969]
  [1.1633]
  [1.1754]
  [1.1616]
  [1.1588]
  </code></pre>
  
  <p>How could I sort the dates with their corresponding values and associate the dates to the label "labels" and the values of the currencies to the label "data" of chart.js?</p>
  
  <p>What I want to get is this:</p>
  
  <pre><code>var fechas = ["2018-05-04", "2018-06-08", "2018-07-19","2018-08-22","2018-08-27"]; // Ordered Dates
  
  var valores = ["1.1969", "1.1754", "1.1588","1.1616","1.1633"]; // Value of the currencies corresponding to the ordered date
  
  </code></pre>