# Sort Pens on Time Series Chart Help

**URL:** <https://forum.inductiveautomation.com/t/sort-pens-on-time-series-chart-help/85778>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [February 15, 2024, 5:47pm UTC](https://forum.inductiveautomation.com/t/sort-pens-on-time-series-chart-help/85778 "2024-02-15T17:47:43Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [February 15, 2024, 7:40pm UTC](https://forum.inductiveautomation.com/t/sort-pens-on-time-series-chart-help/85778/6 "2024-02-15T19:40:42Z")

</div>

First off post code, not pictures of code, with sensitive parts redacted as necessary:

> [@Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831):
>
> This thread is intended as a short help file for all those struggling to post formatted code on the forum. Code block formatting Posting formatted code on the forum (and most others) is as simple as selecting the code and pressing the \</\> button. It works the same as applying Bold or Italic styles to your document. It preserves indentation and applies syntax highlighting. [How to post code] Note that all the \</\> button does is add three backticks ``` on the line before the code block and anot…

Moving onto the ordering problem, you are iterating through the response from `browseTags`, so you are likely at the mercy of whatever order that function returns the tags in.

If you just want alphabetical ordering you can make use of `operator.itemgetter` to sort the resulting list before returning it. Something along the lines of

```python
data = sorted(data, key=operator.itemgetter('alias'))

```

right before assigning the data to `self.custom.data` should work.

If you want specific ordering you'll probably have to do something like use a separate list that has the tag names in the preferred order, that you can then compare against and move items in the data variable to match positions/order.

---

_[View the full topic](https://forum.inductiveautomation.com/t/sort-pens-on-time-series-chart-help/85778)._
