# Sort method of the Table Class doesn’t work correctly

**URL:** <https://discourse.processing.org/t/sort-method-of-the-table-class-doesn-t-work-correctly/40031>\
**Category:** Coding Questions\
**Created:** [December 5, 2022, 11:09am UTC](https://discourse.processing.org/t/sort-method-of-the-table-class-doesn-t-work-correctly/40031 "2022-12-05T11:09:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Schiffmann](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@Schiffmann](https://discourse.processing.org/u/Schiffmann)\
**Post date:** [December 5, 2022, 11:09am UTC](https://discourse.processing.org/t/sort-method-of-the-table-class-doesn-t-work-correctly/40031/1 "2022-12-05T11:09:10Z")

</div>

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

—

```auto
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"));

}

}

```

---

<div class="post-metadata">

**Author:** ![Schiffmann](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@Schiffmann](https://discourse.processing.org/u/Schiffmann)\
**Post date:** [December 5, 2022, 1:43pm UTC](https://discourse.processing.org/t/sort-method-of-the-table-class-doesn-t-work-correctly/40031/2 "2022-12-05T13:43:30Z")

</div>

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