I’ll guess you have to remove the comma and turn them into numbers for your sort to work. Also, making a for loop for the second makes it more elegant and also makes it work if you have more rows in your csv. Haven’t tried it, hope it works on the first run:
values = [];
for(i=0;i<=thisComp.layer("Data-Driven-Sample.csv")("Data")("Number of Rows")-1;i++) {
rowVal = thisComp.layer("Data-Driven-Sample.csv")("Data")("Outline")("Number Data")("Number Data " + i).value;
values.push(parseInt(rowVal.replace(",","")));
}
values.sort((a, b) => b - a);
values.join("\n");
// code on the corresponding item list to be sorted based on descending values of the above numbers list
examples = [];
for (i = 0;i <= thisComp.layer("Data-Driven-Sample.csv")("Data")("Number of Rows") - 1;i++) {
var rowVal = {};
rowVal.text = thisComp.layer("Data-Driven-Sample.csv")("Data")("Outline")("Text Data")("Text Data 0");
rowVal.number = parseInt(thisComp.layer("Data-Driven-Sample.csv")("Data")("Outline")("Number Data")("Number Data "+i).replace(",",""));
examples.push(rowVal);
}
const list = examples.sort((a,b) => b.number-a.number).map((examples, number, array) => examples.text);
list.join("\n");
Andrei
My Envato portfolio.