# Sort the columns of a power table using scripting

**URL:** <https://forum.inductiveautomation.com/t/sort-the-columns-of-a-power-table-using-scripting/44264>\
**Category:** Ignition\
**Created:** [March 9, 2021, 3:10pm UTC](https://forum.inductiveautomation.com/t/sort-the-columns-of-a-power-table-using-scripting/44264 "2021-03-09T15:10:00Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 9, 2021, 5:53pm UTC](https://forum.inductiveautomation.com/t/sort-the-columns-of-a-power-table-using-scripting/44264/2 "2021-03-09T17:53:23Z")

</div>

Do you want to apply the sort in a way that the user can add/remove?

> [@Power Table Sort Script](http://forum.inductiveautomation.com/t/power-table-sort-script/15524):
>
> For those of you who would like to know how to trigger a Power Table to sort via script, here is how you do it: table = event.source.parent.getComponent(‘Table’) gTable = table.getTable() gTable.setAutoCreateRowSorter(True) gTable.getRowSorter().toggleSortOrder(0) # the 0 (zero) sets which column to sort on

Or do you just want to pre-sort the data, in which case all you need is to invoke `system.dataset.sort` or the `sortDataset` expression function: [sortDataset - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/sortDataset)

---

_[View the full topic](https://forum.inductiveautomation.com/t/sort-the-columns-of-a-power-table-using-scripting/44264)._
