title: Sort a Chart from Lowest to Highest Value in Chart JS
body: <p>I have this starting code and I'm tryng to figure out how I can sort this data from the highest to the lowest. The code can sort correctly the values but the labels in the yAxis are wrong.</p>
  <p>I've tried myself but this code is advanced for me to understand.</p>
  <p>Here's the snippet</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>//after the data is sorted
    let meta = chart.getDatasetMeta(0);
    let newMeta = [];
    let labels = chart.data.labels;
    let newLabels = [];
    
  
    meta.data.forEach((a, i) =&gt; {
      newMeta[dataIndexes[i]] = a;
      newLabels[dataIndexes[i]] = chart.data.labels[i];
    });
  
    meta.data = newMeta;
    chart.data.datasets[0].data = dataArray;
    chart.data.labels = newLabels;
      }
    }</code></pre>
  </div>
  </div>
  </p>
  <p>The full code is here: <a href="https://jsfiddle.net/3seduh9k/" rel="nofollow noreferrer">https://jsfiddle.net/3seduh9k/</a></p>