# Sort a List of Dictionaries

**URL:** <https://forum.inductiveautomation.com/t/sort-a-list-of-dictionaries/22490>\
**Category:** Ignition\
**Created:** [February 11, 2019, 11:37pm UTC](https://forum.inductiveautomation.com/t/sort-a-list-of-dictionaries/22490 "2019-02-11T23:37:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![larryjones](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/larryjones/32/4102_2.png) [@larryjones](https://forum.inductiveautomation.com/u/larryjones)\
**Post date:** [February 11, 2019, 11:37pm UTC](https://forum.inductiveautomation.com/t/sort-a-list-of-dictionaries/22490/1 "2019-02-11T23:37:22Z")

</div>

Can anyone provide guidance for how to sort a List of Dictionaries in an Ignition scrip? I’m using the scripting function system.tag.browseConfiguration and I want to sort the results on the ‘name’ key. I did a little research and found that something like the following should work but it doesn’t:

tagConfig = system.tag.browseConfiguration(UDTtagPath, True)  
tagConfigSorted = sorted(tagConfig, key=lambda k: k[‘name’])

I get the error message: ‘com.inductiveautomation.ignition.common.tags.config.TagConfiguration’ object is unsubscriptable

Thank you.

---

<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:** [February 11, 2019, 11:48pm UTC](https://forum.inductiveautomation.com/t/sort-a-list-of-dictionaries/22490/2 "2019-02-11T23:48:43Z")

</div>

Try

```auto
 tagConfigSorted = sorted(tagConfig, key=lambda k: k.get('name'))

```

The ‘unsubscriptable’ error is referring the the square bracket syntax.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 11, 2019, 11:49pm UTC](https://forum.inductiveautomation.com/t/sort-a-list-of-dictionaries/22490/3 "2019-02-11T23:49:18Z")

</div>

> [@paul-griffith](#):
>
> The ‘unsubscriptable’ error is referring the the square bracket syntax.

Because a `TagConfiguration` isn't a dictionary.

You beat me to it 😛

---

<div class="post-metadata">

**Author:** ![larryjones](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/larryjones/32/4102_2.png) [@larryjones](https://forum.inductiveautomation.com/u/larryjones)\
**Post date:** [February 12, 2019, 1:41am UTC](https://forum.inductiveautomation.com/t/sort-a-list-of-dictionaries/22490/4 "2019-02-12T01:41:37Z")

</div>

Thank you both for the help. I see now that the system.tag.browseConfiguration function returns a list of TagConfiguration objects. The suggested code, however, does not work. The error message is:

TypeError: get(): 1st arg can’t be coerced to com.inductiveautomation.ignition.common.config.Property

How do I replace ‘name’ with a property object called “name”?

Thank you.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 12, 2019, 1:47am UTC](https://forum.inductiveautomation.com/t/sort-a-list-of-dictionaries/22490/5 "2019-02-12T01:47:54Z")

</div>

In this case I think you can actually use `k.getName()` because `TagConfiguration` happens to have a `getName()` method on it.

---

<div class="post-metadata">

**Author:** ![larryjones](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/larryjones/32/4102_2.png) [@larryjones](https://forum.inductiveautomation.com/u/larryjones)\
**Post date:** [February 12, 2019, 2:17am UTC](https://forum.inductiveautomation.com/t/sort-a-list-of-dictionaries/22490/6 "2019-02-12T02:17:59Z")

</div>

Kevin,

That worked.

Thank you,

Larry
