# List sorting

**URL:** <https://forum.dynamobim.com/t/list-sorting/3043>\
**Category:** Packages\
**Created:** [January 29, 2016, 3:02am UTC](https://forum.dynamobim.com/t/list-sorting/3043 "2016-01-29T03:02:43Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Uaifestival](https://avatars.discourse-cdn.com/v4/letter/u/47e85d/32.png) [@Uaifestival](https://forum.dynamobim.com/u/Uaifestival)\
**Post date:** [January 29, 2016, 3:02am UTC](https://forum.dynamobim.com/t/list-sorting/3043/1 "2016-01-29T03:02:43Z")

</div>

I woud love to order a list where 15 is \< 142 and not viceversa. They are viewsname, after ordering them I can place them properly. What node should i pick to transform this order into the desired one. ![bandicam 2016-01-29 17-27-44-993](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/2X/9/9181151b2247251d4eee6c9c67887c764746233e.jpg)

---

<div class="post-metadata">

**Author:** ![Dimitar\_Venkov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dimitar_venkov/32/2068_2.png) [@Dimitar\_Venkov](https://forum.dynamobim.com/u/Dimitar_Venkov)\
**Post date:** [January 29, 2016, 3:44am UTC](https://forum.dynamobim.com/t/list-sorting/3043/2 "2016-01-29T03:44:36Z")

</div>

Hello,

Do a search on the forum for “String.PadLeft” for some examples on how to sort strings “numerically”.

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [January 29, 2016, 5:25am UTC](https://forum.dynamobim.com/t/list-sorting/3043/3 "2016-01-29T05:25:52Z")

</div>

![20160129-3](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/2X/c/c235c01c297642e8c996535e374632c6754fce25.png)

---

<div class="post-metadata">

**Author:** ![Dimitar\_Venkov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dimitar_venkov/32/2068_2.png) [@Dimitar\_Venkov](https://forum.dynamobim.com/u/Dimitar_Venkov)\
**Post date:** [January 29, 2016, 6:02am UTC](https://forum.dynamobim.com/t/list-sorting/3043/4 "2016-01-29T06:02:48Z")

</div>

Stellar idea, Vikram! If we use “String.ToNumber” in a composed function, we can sort the list without modifying the original strings:

 ![DynamoSandbox_2016-01-29_19-30-32](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/2X/0/0dfcae4c848dea2b25cc3f1fedf9fa5f7c9418c7.png)

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [January 29, 2016, 9:45am UTC](https://forum.dynamobim.com/t/list-sorting/3043/5 "2016-01-29T09:45:12Z")

</div>

Just responded to a question [here](http://dynamobim.org/forums/topic/sort-list-by-sublist/#post-37609) with a similar solution…

Used _List.SortByKey_ though

 ![20160129-4](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/2X/b/b3b8e582f75655a052e1a66bc40fe116b0e9e811.png)

---

<div class="post-metadata">

**Author:** ![Uaifestival](https://avatars.discourse-cdn.com/v4/letter/u/47e85d/32.png) [@Uaifestival](https://forum.dynamobim.com/u/Uaifestival)\
**Post date:** [February 1, 2016, 12:35am UTC](https://forum.dynamobim.com/t/list-sorting/3043/6 "2016-02-01T00:35:58Z")

</div>

Thanks. 2 solutions are better than one. I used the string to number than after sorting it, adding again the “P” I actually tried both but I could not applied properly Venkov one - [here](http://dynamobim.org/forums/topic/list-sorting/#post-37726)- it results that 43P is before 11P and the warns is _Asked to convert non-convertible types_"

 ![bandicam 2016-02-01 15-03-33-802](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/2X/0/019e6fa73c30ac58d908b5d988360f26ae468644.jpg) Next thread is next question.

---

<div class="post-metadata">

**Author:** ![Uaifestival](https://avatars.discourse-cdn.com/v4/letter/u/47e85d/32.png) [@Uaifestival](https://forum.dynamobim.com/u/Uaifestival)\
**Post date:** [February 1, 2016, 1:16am UTC](https://forum.dynamobim.com/t/list-sorting/3043/7 "2016-02-01T01:16:57Z")

</div>

I am trying to get the elements (perspective views) ordered as the names are, so I can set them properly, but probably I am mixing things up somewhere…

Anyway it seems the compose function fails.

This time the warning is different:

Warning: One or more of the input types are not matching. Couldn’t find a version of \_\_Compose that takes arguments of type (\_\_array)

 ![bandicam 2016-02-01 15-44-41-703](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/2X/8/87f7cf989430917d1ccd7181f6c028e2db13870d.jpg)

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [February 1, 2016, 7:00am UTC](https://forum.dynamobim.com/t/list-sorting/3043/8 "2016-02-01T07:00:39Z")

</div>

Note that Dimitar had left the **_str_** input port un-wired for both nodes connected to _Function.Compose_ (_String.Replace_ and _String.ToNumber)_

---

<div class="post-metadata">

**Author:** ![Uaifestival](https://avatars.discourse-cdn.com/v4/letter/u/47e85d/32.png) [@Uaifestival](https://forum.dynamobim.com/u/Uaifestival)\
**Post date:** [February 1, 2016, 10:15pm UTC](https://forum.dynamobim.com/t/list-sorting/3043/9 "2016-02-01T22:15:05Z")

</div>

thanks. I do not know previously I had tried unplugged but it did not work, probably others mistakes were there. This time worked smoothly.

Now I am addressing in how to call the view with this new order…[here](http://dynamobim.org/forums/topic/renaming-views/#post-37729) details on renaming views thread, how node should I pick this time. I tried [item.by](http://item.by) index but it did not work…

---

<div class="post-metadata">

**Author:** ![Michal\_Dengusiak](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/michal_dengusiak/32/92831_2.png) [@Michal\_Dengusiak](https://forum.dynamobim.com/u/Michal_Dengusiak)\
**Post date:** [February 15, 2016, 5:19pm UTC](https://forum.dynamobim.com/t/list-sorting/3043/10 "2016-02-15T17:19:14Z")

</div>

I am struggling a bit with sorting… I have list of elements lets say rooms, I use Element.GetParametrerValueByName and using area to extract this data. I can now sort area list but how I can sort my original elements list with area sorting? I want to use numbering at each level from 1…end…1 sorted by area so No1 will have biggest number

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [February 16, 2016, 12:52am UTC](https://forum.dynamobim.com/t/list-sorting/3043/11 "2016-02-16T00:52:04Z")

</div>

File: [RoomNumberByArea.dyn](http://dynamobim.org/wp-content/uploads/forum-assets/testingwaters/02/16/RoomNumberByArea1.dyn)

![20160216-3](http://dynamobim.org/wp-content/uploads/forum-assets/testingwaters/02/16/20160216-31.png)

&nbsp;

---

<div class="post-metadata">

**Author:** ![Jorge\_Villarroel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jorge_villarroel/32/23619_2.png) [@Jorge\_Villarroel](https://forum.dynamobim.com/u/Jorge_Villarroel)\
**Post date:** [January 4, 2017, 2:59am UTC](https://forum.dynamobim.com/t/list-sorting/3043/12 "2017-01-04T02:59:23Z")

</div>

Hi @Vikram_Subbaiah, I’m struggling with the same type of sorting buy for the surface area of an exploded solid. Meaning: I want to sort the list of surfaces by its areas from the small to big.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [January 12, 2017, 11:27am UTC](https://forum.dynamobim.com/t/list-sorting/3043/13 "2017-01-12T11:27:49Z")

</div>

@Jorge_Villarroel Hope this helps

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

---

<div class="post-metadata">

**Author:** ![Jorge\_Villarroel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jorge_villarroel/32/23619_2.png) [@Jorge\_Villarroel](https://forum.dynamobim.com/u/Jorge_Villarroel)\
**Post date:** [January 17, 2017, 11:23pm UTC](https://forum.dynamobim.com/t/list-sorting/3043/14 "2017-01-17T23:23:11Z")

</div>

Thanks! This is what I was looking for. Regards
