1 const arrayOfObj = chartLabels.map(function (d, i) {
2 return {
3 label: d,
4 data: chartValues[i] || 0,
5 }
6 })
7
8 const sortedArrayOfObj = arrayOfObj.sort(function (a, b) {
9 return b.data - a.data
10 })
11
12 let newArrayLabel = []
13 let newArrayData = []
14 sortedArrayOfObj.forEach(function (d) {
15 newArrayLabel.push(d.label)
16 newArrayData.push(d.data)
17 })