# Sort Numbers

**URL:** <https://forum.dynamobim.com/t/sort-numbers/62083>\
**Category:** Lists-Logic\
**Created:** [March 24, 2021, 11:51pm UTC](https://forum.dynamobim.com/t/sort-numbers/62083 "2021-03-24T23:51:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gerhard.p](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gerhard.p/32/147675_2.png) [@gerhard.p](https://forum.dynamobim.com/u/gerhard.p)\
**Post date:** [March 24, 2021, 11:51pm UTC](https://forum.dynamobim.com/t/sort-numbers/62083/1 "2021-03-24T23:51:57Z")

</div>

Hello,

I would like to sort numbers in an order like this:

1.2.8  
1.2.9  
1.2.10  
1.10.12

But with dynamo i get the result:

1.10.12  
1.2.10  
1.2.8  
1.2.9

I will now use the workaround that i use the style like 01.02.03, that works.  
Just wanted to ask if there would be any way to sort the list like i wanted to do in first place.

Thanks for any help!

Kind Regards!

---

<div class="post-metadata">

**Author:** ![AmolShah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/amolshah/32/103244_2.png) [@AmolShah](https://forum.dynamobim.com/u/AmolShah)\
**Post date:** [March 25, 2021, 12:26am UTC](https://forum.dynamobim.com/t/sort-numbers/62083/2 "2021-03-25T00:26:15Z")

</div>

@gerhard.p You need something called natural sort.

Try this:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/f/0fec6c05270b7e195b60aaa8bc203c2329ceb4a8.png)

```auto
import re

def natural_sort(l): 
    convert = lambda text: int(text) if text.isdigit() else text.lower() 
    alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key) ] 
    return sorted(l, key = alphanum_key)
    
OUT = natural_sort(IN[0])

```

Alternatively, you can use the Natural Sort node from Orchid package

---

<div class="post-metadata">

**Author:** ![gerhard.p](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/gerhard.p/32/147675_2.png) [@gerhard.p](https://forum.dynamobim.com/u/gerhard.p)\
**Post date:** [March 25, 2021, 5:53pm UTC](https://forum.dynamobim.com/t/sort-numbers/62083/3 "2021-03-25T17:53:44Z")

</div>

Natural sort, thats a thing i know now, thank you so much 😀
