# Perspective table sort order working in designer, not at runtime

**URL:** <https://forum.inductiveautomation.com/t/perspective-table-sort-order-working-in-designer-not-at-runtime/111167>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [October 3, 2025, 4:45am UTC](https://forum.inductiveautomation.com/t/perspective-table-sort-order-working-in-designer-not-at-runtime/111167 "2025-10-03T04:45:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ASF](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@ASF](https://forum.inductiveautomation.com/u/ASF)\
**Post date:** [October 3, 2025, 4:45am UTC](https://forum.inductiveautomation.com/t/perspective-table-sort-order-working-in-designer-not-at-runtime/111167/1 "2025-10-03T04:45:03Z")

</div>

I have a perspective table which populates data via a binding with a transform script. When I set up the sorting parameters, I can manipulate the table into sorting itself into any order I wish, and it works in the designer in preview mode. However in a web browser session, when the table loads it loads with no sorting, and just has the rows populated in the order they appear in the data array. What could be the cause?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 3, 2025, 8:18am UTC](https://forum.inductiveautomation.com/t/perspective-table-sort-order-working-in-designer-not-at-runtime/111167/2 "2025-10-03T08:18:41Z")

</div>

Check that you have all the settings correct as shown in **sortOrder** in [Perspective - Table | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/components/perspective-components/perspective-display-palette/perspective-table#properties).

> The default weighted order in which columns and their contents are sorted relative to other columns and their contents. Used when the component loads. For **sortOrder** to be applied, the table must meet the following requirements:

> - Objects under the **columns** array must be defined for each column in the table's underlying data property you wish to display and sort on.
> - In addition, each object under columns must have the **field** setting set to the data item under the data property (for example, "population" in the table's default data set).
> - **sortable** must be enabled.
> - **sort** must be set to something other than none.

> Once all columns have been configured, the sortOrder can be configured.Each element in the **sortOrder** array is expected to be a string value representing the name of the column (as determined by **field** value in the columns array). For example, sorting by population first, city second, and country last, would look like the following:  
> ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/1/b107dc6fdd1899d54d1c9c8e510a2a424281bf28.png)

Go through the four bullet points carefully.

---

<div class="post-metadata">

**Author:** ![ASF](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@ASF](https://forum.inductiveautomation.com/u/ASF)\
**Post date:** [October 6, 2025, 10:08pm UTC](https://forum.inductiveautomation.com/t/perspective-table-sort-order-working-in-designer-not-at-runtime/111167/3 "2025-10-06T22:08:43Z")

</div>

Thanks, I’ve gone through those four points carefully and can confirm that it behaves as expected when previewing in the designer. If I set the sortOrder to `0: name, 1: code` then hit preview, it sorts the data that way. If I stop preview, and change the sortOrder to `0: code, 1: name` and then click preview again, it re-sorts in the expected order. If I change the sort setting on the top priority sort column from ascending to descending and click preview, the data sorts itself in descending order instead of ascending. It all works exactly as expected when I preview in the designer, but in a session, it just loads them in the order the data appears in the table data binding. I can use the sort controls to sort afterward, but when it first loads, it does not sort.

Could this maybe be something to do with the fact that in the designer, the binding has already executed and loaded the data into the table when I click preview, so the sorting is acting on data that’s already there? Whereas at runtime, perhaps it tries to sort the data before the binding is finalised, so then the “new” data is just added in unsorted?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 6, 2025, 10:53pm UTC](https://forum.inductiveautomation.com/t/perspective-table-sort-order-working-in-designer-not-at-runtime/111167/4 "2025-10-06T22:53:23Z")

</div>

Yes, that sounds likely. I wonder can you set the sortOrder by script _after_ the binding has loaded the data? I think I've seen post about detecting the end of the data binding update but can't find them. Perhaps an onChange event on `data`?

The other option, of course, is to sort in your SQL query.

---

<div class="post-metadata">

**Author:** ![ASF](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@ASF](https://forum.inductiveautomation.com/u/ASF)\
**Post date:** [October 6, 2025, 11:11pm UTC](https://forum.inductiveautomation.com/t/perspective-table-sort-order-working-in-designer-not-at-runtime/111167/5 "2025-10-06T23:11:11Z")

</div>

That’s an idea. In this case my data comes not from a SQL query but from a script transform that is reading data from multiple places and assembling it into a table (yes, I know that a database is the nice way to do this, but this is just an edge project and I can’t guarantee connectivity to the database).

But that being the case, it makes your suggestion even easier - just set the sortOrder at the end of the script. Let me give that a try…

---

<div class="post-metadata">

**Author:** ![ASF](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@ASF](https://forum.inductiveautomation.com/u/ASF)\
**Post date:** [October 6, 2025, 11:21pm UTC](https://forum.inductiveautomation.com/t/perspective-table-sort-order-working-in-designer-not-at-runtime/111167/6 "2025-10-06T23:21:07Z")

</div>

Unfortunately that doesn’t seem to work either.

Looks like sorting the data before I load it into the table is my best option. In consultation with my friendly AI assistant, I’ve found that I can add the following line to my script just before I return `data` to sort it into the desired order:

`data.sort(key=lambda x: str(x["product"]).lower())`

In this case the column I want to sort by is `product` and I added the `lower()` to make the sort case insensitive.
