# How to sort stations in Script in Flexrepeater

**URL:** <https://forum.inductiveautomation.com/t/how-to-sort-stations-in-script-in-flexrepeater/40131>\
**Category:** Ignition\
**Created:** [October 29, 2020, 12:28pm UTC](https://forum.inductiveautomation.com/t/how-to-sort-stations-in-script-in-flexrepeater/40131 "2020-10-29T12:28:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![a.krishnamanidhar](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@a.krishnamanidhar](https://forum.inductiveautomation.com/u/a.krishnamanidhar)\
**Post date:** [October 29, 2020, 12:28pm UTC](https://forum.inductiveautomation.com/t/how-to-sort-stations-in-script-in-flexrepeater/40131/1 "2020-10-29T12:28:38Z")

</div>

Dear All,

I have multiple stations available, I am trying to add them to a breakpoint container and perform sort based on status using flexrepeater and adding instances.

I am confused on what to add the script in Instances transform in flexrepeater. I am new to Ignition modules scripting. Any help would really be great.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [October 29, 2020, 1:41pm UTC](https://forum.inductiveautomation.com/t/how-to-sort-stations-in-script-in-flexrepeater/40131/2 "2020-10-29T13:41:42Z")

</div>

Python sorting is pretty neat, but you need to supply a “key” which will be used to sort the list.

In this example case, assume that I have multiple instances which I would like sorted by the value of a property named “`bayId`”.

![Screen Shot 2020-10-29 at 6.34.17AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/9/b92495506d1b0ecbe56598daf15b280f8cf9e2da.png)

I would use Python’s `sort()` [function for lists](https://docs.python.org/2/howto/sorting.html) and I would supply a function which supplies the value I would like to use to sort the list.

```auto
# Here, the lambda will return the bayId value from each instance and use it as the value to determine the order
value.sort(key=lambda e: e.bayId)
return value

```

This should function the same way:

```auto
def get_bay_id(instance):
    return instance.bayId

# Note that here you only need to supply the function without values.
# The sort() function will use the supplied function and implicitly supply each instance.
value.sort(key=get_bay_id)
return value

```
