var data = {
chart : 'rank',
labels: [
{
0: 'First Choice'
1: 'Second Choice',
2: 'Third Choice',
3: 'Fourth Choice',
4: 'Fifth Choice'
}
],
rows: [
{
0: 2,
1: 8,
2: 1,
3: 30
4: 4
}
]
}
Is there a way to reorder the results so that the rows are reordered highest to lowest and the corresponding labels are reordered too like the below:
var data = {
chart : 'rank',
labels: [
{
0: 'Fourth Choice'
1: 'Second Choice',
2: 'Fifth Choice',
3: 'First Choice',
4: 'Third Choice'
}
],
rows: [
{
0: 30,
1: 8,
2: 4,
3: 2
4: 1
}
]
}
So far I have managed to reorder the rows array using the following but stuck when it comes to labels?
rows = rows.sort(function(a, b){return b-a});