# Table sort order

**URL:** <https://forum.inductiveautomation.com/t/table-sort-order/1948>\
**Category:** Ignition\
**Created:** [June 17, 2010, 12:00pm UTC](https://forum.inductiveautomation.com/t/table-sort-order/1948 "2010-06-17T12:00:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlThePal](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/althepal/32/3603_2.png) [@AlThePal](https://forum.inductiveautomation.com/u/AlThePal)\
**Post date:** [June 17, 2010, 12:00pm UTC](https://forum.inductiveautomation.com/t/table-sort-order/1948/1 "2010-06-17T12:00:02Z")

</div>

I have a window with 2 buttons to swap entries between 2 tables. I manually populate both tables with data when the window opens. When I swap an entry from one table to another, I would like the table to be displayed in alphabetical order. I can achieve this by clicking on the appropriate column header once the window is opened, but can I either sort the table in code, or force the table to default to sorting by a particular column when the window opens?

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [June 18, 2010, 5:20pm UTC](https://forum.inductiveautomation.com/t/table-sort-order/1948/2 "2010-06-18T17:20:02Z")

</div>

> [@AlThePal](#):
>
> I manually populate both tables with data when the window opens...

This seems like a good step to do the sorting in. We can add a "sortByColumn(columnName)" function, but in the meantime seems like you could do this yourself.

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [June 18, 2010, 11:15pm UTC](https://forum.inductiveautomation.com/t/table-sort-order/1948/3 "2010-06-18T23:15:31Z")

</div>

We went ahead and added:

```auto
table.sortByColumn("MyColumn", 0)
```

where the 2nd argument is 1=ascending, 0=descenging, and

```auto
table.sortOriginal()
```

for 7.1.3

---

<div class="post-metadata">

**Author:** ![dep05d](https://avatars.discourse-cdn.com/v4/letter/d/e495f1/32.png) [@dep05d](https://forum.inductiveautomation.com/u/dep05d)\
**Post date:** [June 18, 2010, 11:28pm UTC](https://forum.inductiveautomation.com/t/table-sort-order/1948/4 "2010-06-18T23:28:59Z")

</div>

While we’re on the topic of tables and sorting, would it be possible to add an option to the table component to disable the ability to sort by clicking the column headers? Although I don’t have a designer handy, I’m pretty sure even if the table is not enabled, the user can still sort. For certain datasets, such as recipes, it doesn’t make much sense to sort anything, and would probably only add confusion if a sort was accidentally clicked and the operator didn’t realize/undo it.

Thanks,

Dan

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [June 18, 2010, 11:40pm UTC](https://forum.inductiveautomation.com/t/table-sort-order/1948/5 "2010-06-18T23:40:24Z")

</div>

Yeah that sounds reasonable, I’ll take a look

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [June 21, 2010, 5:19pm UTC](https://forum.inductiveautomation.com/t/table-sort-order/1948/6 "2010-06-21T17:19:59Z")

</div>

Ok, this is done for 7.1.3
