Sort method of the Table Class doesn’t work correctly

Hello,

I wrote a program that should sort a table according a column with int values that were initialised in descending order, starting with 100000. Unfortunately the result is wrong while by excel or numbers it can be sorted correctly.

Is this problem already known? Or what could be the reason? Is my (attached) code faulty?

Best regards,

Wolfram

Table testData;

int i;

void setup(){

noLoop();

size(100,100);

testData = new Table();

testData.addColumn("value");

}

void draw(){

for(i=100000;i>=0;i--){

TableRow newRow=testData.addRow();

newRow.setInt("value",i);

}

testData.trim();

testData.sort("value");

saveTable(testData,"testData.csv");

for(i=0;i<10;i++){

TableRow row=testData.getRow(i);

println(i,":", row.getInt("value"));

}

}

Found the error in my code. In the addColumn method I had to define the data type an additional argument.
Best regards, Wolfram

1 Like