# Sort Revit Elements by Number then Letter

**URL:** <https://forum.dynamobim.com/t/sort-revit-elements-by-number-then-letter/14305>\
**Category:** Lists-Logic\
**Created:** [August 25, 2017, 5:50pm UTC](https://forum.dynamobim.com/t/sort-revit-elements-by-number-then-letter/14305 "2017-08-25T17:50:11Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jay.polding](https://avatars.discourse-cdn.com/v4/letter/j/85e7bf/32.png) [@jay.polding](https://forum.dynamobim.com/u/jay.polding)\
**Post date:** [August 25, 2017, 5:50pm UTC](https://forum.dynamobim.com/t/sort-revit-elements-by-number-then-letter/14305/1 "2017-08-25T17:50:12Z")

</div>

Hi,

I’m trying to sort Revit Elements by number then by letter. I would prefer to only use Dynamo and no Python.

The Revit Elements have a parameter for each i.e. loadNumber = 1, loadLetter = A. My resulting Element need to be sorted somthing like this:  
1  
1A  
1B  
2  
3  
4  
5  
6  
7  
7A  
7B  
8  
9  
10  
10A  
10B

When I SortbyKey using the loadNumber, it works. When I then try to SortbyKey for the loadLetter it doesn’t work. Seems that SortbyKey is using numbers only.

[GRAPHIC COLUMN AND WALL SCHEDULE GRAPH.dyn](https://forum.dynamobim.com/uploads/short-url/o4Wk8t59qH2ycuDbE1ic7JZY6EO.dyn) (95.8 KB)

[GRAPHIC COLUMN AND WALL SCHEDULE.rvt](https://forum.dynamobim.com/uploads/short-url/tSMJeyBVlRmWFOYcjn8tGmV3qo1.rvt) (2.6 MB)

---

<div class="post-metadata">

**Author:** ![Andreas\_Dieckmann](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/andreas_dieckmann/32/365_2.png) [@Andreas\_Dieckmann](https://forum.dynamobim.com/u/Andreas_Dieckmann)\
**Post date:** [August 25, 2017, 6:24pm UTC](https://forum.dynamobim.com/t/sort-revit-elements-by-number-then-letter/14305/2 "2017-08-25T18:24:15Z")

</div>

![SortWithRegExp](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/5/6591429d62ee0af03a7d4480a40eb091d4e0cc71.PNG)

---

<div class="post-metadata">

**Author:** ![jay.polding](https://avatars.discourse-cdn.com/v4/letter/j/85e7bf/32.png) [@jay.polding](https://forum.dynamobim.com/u/jay.polding)\
**Post date:** [August 25, 2017, 6:49pm UTC](https://forum.dynamobim.com/t/sort-revit-elements-by-number-then-letter/14305/3 "2017-08-25T18:49:19Z")

</div>

Thanks Andreas for the quick reply. I need to explain myself further. I’m looking to sort the ‘Revit Elements’. I am able to sort ‘the list’ adequately by combining the two strings and then using list.sort. What I’m finding is that I’m able to get a sorted list but not sorted ‘Revit Elements’. I want to pull more parameters from the sorted Revit Elements after I have organized them by number then letter. Hope this makes sense.

This fits into a bigger picture of trying to make a custom Graphical Column and Wall Schedule.

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [August 25, 2017, 7:13pm UTC](https://forum.dynamobim.com/t/sort-revit-elements-by-number-then-letter/14305/4 "2017-08-25T19:13:04Z")

</div>

You’ll have to sort your lists twice. Rather than using the parameter values as the `list` input as well as the key values, use the element list instead.  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/4/d40b91ccf7f9dc8c51df3431bb35852a2a541fcd.png)

---

<div class="post-metadata">

**Author:** ![jay.polding](https://avatars.discourse-cdn.com/v4/letter/j/85e7bf/32.png) [@jay.polding](https://forum.dynamobim.com/u/jay.polding)\
**Post date:** [August 25, 2017, 7:34pm UTC](https://forum.dynamobim.com/t/sort-revit-elements-by-number-then-letter/14305/5 "2017-08-25T19:34:22Z")

</div>

Thanks Nick. As you can see from the Graph that I posted, I did plug the Element list into the ‘list’ input.

It gives an error ‘Warning: List.SortByKey operation failed.  
One or more input types are not matching. Lists as keys are not supported.’

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [August 25, 2017, 7:47pm UTC](https://forum.dynamobim.com/t/sort-revit-elements-by-number-then-letter/14305/6 "2017-08-25T19:47:04Z")

</div>

Just as the warning says, keys cannot have sublists. You’ll either need to flatten your lists or use levels.  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/5/65f63c14ad619cb345ef92086179bf4ec269aa44.png)

---

<div class="post-metadata">

**Author:** ![jay.polding](https://avatars.discourse-cdn.com/v4/letter/j/85e7bf/32.png) [@jay.polding](https://forum.dynamobim.com/u/jay.polding)\
**Post date:** [August 25, 2017, 7:50pm UTC](https://forum.dynamobim.com/t/sort-revit-elements-by-number-then-letter/14305/7 "2017-08-25T19:50:06Z")

</div>

The lists match, maybe this graphic will help.

 ![2017-08-25 3-46-17 PM](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/d/0d449ac6e8ec8d7c3ac9bb28351115bcb35d6f62.png)

---

<div class="post-metadata">

**Author:** ![jay.polding](https://avatars.discourse-cdn.com/v4/letter/j/85e7bf/32.png) [@jay.polding](https://forum.dynamobim.com/u/jay.polding)\
**Post date:** [August 25, 2017, 7:52pm UTC](https://forum.dynamobim.com/t/sort-revit-elements-by-number-then-letter/14305/8 "2017-08-25T19:52:31Z")

</div>

Here’s another version I tried…

 ![2017-08-25 3-50-51 PM](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/c/0c26bf7a40b397fb19152f213a1353ccde009c80.png)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [August 25, 2017, 7:53pm UTC](https://forum.dynamobim.com/t/sort-revit-elements-by-number-then-letter/14305/9 "2017-08-25T19:53:48Z")

</div>

Your list of keys going into the second SortByKey is a list of lists. This is not supported for keys. You’ll have to use levels.

---

<div class="post-metadata">

**Author:** ![jay.polding](https://avatars.discourse-cdn.com/v4/letter/j/85e7bf/32.png) [@jay.polding](https://forum.dynamobim.com/u/jay.polding)\
**Post date:** [August 25, 2017, 7:59pm UTC](https://forum.dynamobim.com/t/sort-revit-elements-by-number-then-letter/14305/10 "2017-08-25T19:59:56Z")

</div>

Thanks, looks like we’re getting closer by pressing ‘use Levels’. Any ideas on a next step?

 ![2017-08-25 3-57-50 PM](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/1/a1834cee509eeda7396b6b5effaf124512aacd3d.png)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [August 25, 2017, 8:19pm UTC](https://forum.dynamobim.com/t/sort-revit-elements-by-number-then-letter/14305/11 "2017-08-25T20:19:41Z")

</div>

You need to pick the correct level(s) to get the lacing you’re looking for. Levels are just the list dimensions in an output. You can see at the bottom left of the preview (or watch node) the levels available in that list. Iterating the keys input over a level 2 list in this case will run each sublist like its own list of keys.

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

---

<div class="post-metadata">

**Author:** ![jay.polding](https://avatars.discourse-cdn.com/v4/letter/j/85e7bf/32.png) [@jay.polding](https://forum.dynamobim.com/u/jay.polding)\
**Post date:** [August 25, 2017, 8:34pm UTC](https://forum.dynamobim.com/t/sort-revit-elements-by-number-then-letter/14305/12 "2017-08-25T20:34:50Z")

</div>

Thanks, this is on the right track for sure. It must be some combination of lacing and levels. See if this makes sense…

 ![2017-08-25 4-32-39 PM](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/3/e3057395ac34f0146057d6f919b5f89a0bbc4e5b.png)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [August 25, 2017, 8:57pm UTC](https://forum.dynamobim.com/t/sort-revit-elements-by-number-then-letter/14305/13 "2017-08-25T20:57:34Z")

</div>

Can you post an image of your whole graph, or at least the part showing how you got the parameter values initially? I’m confused as to why your lists don’t match in the first place.

---

<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:** [August 26, 2017, 1:31am UTC](https://forum.dynamobim.com/t/sort-revit-elements-by-number-then-letter/14305/14 "2017-08-26T01:31:43Z")

</div>

@jay.polding See if this solves your problem  
[20170826-1.dyn](https://forum.dynamobim.com/uploads/short-url/3MPMYDTwaS6T9LpPeNoyirykChO.dyn) (13.0 KB)

 ![20170826-1](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/a/bab5fd4d2f53f73c7aea1def87eef3e6f4dbed87.png)

---

<div class="post-metadata">

**Author:** ![jay.polding](https://avatars.discourse-cdn.com/v4/letter/j/85e7bf/32.png) [@jay.polding](https://forum.dynamobim.com/u/jay.polding)\
**Post date:** [August 28, 2017, 2:39pm UTC](https://forum.dynamobim.com/t/sort-revit-elements-by-number-then-letter/14305/15 "2017-08-28T14:39:13Z")

</div>

Thanks Vikram,

Although your Graph does produce a list, it is just a list of Strings and not a list of Elements. I’m looking to sort the Elements so I can work with them further. For instance, I would like to getparameter for Family Type or Mark or some other parameter.

---

<div class="post-metadata">

**Author:** ![jay.polding](https://avatars.discourse-cdn.com/v4/letter/j/85e7bf/32.png) [@jay.polding](https://forum.dynamobim.com/u/jay.polding)\
**Post date:** [August 28, 2017, 2:50pm UTC](https://forum.dynamobim.com/t/sort-revit-elements-by-number-then-letter/14305/16 "2017-08-28T14:50:35Z")

</div>

Thanks so much for looking into this issue Nick, I have attached the images as well as the graph.

 ![1](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/9/39bd31130f880b41c1d48975c05ba280bd31d741.png) ![2](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/9/09e4374b9c24dd14ecdcd66b22e1e56bd39ef4ec.png) ![3](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/4/647960f744f2968eb5f978215b650880e2ce2ccd.png)

[GRAPHIC COLUMN AND WALL SCHEDULE GRAPH.dyn](https://forum.dynamobim.com/uploads/short-url/hCmocAEVh6PRn9Go9SPOT4sU1oe.dyn) (96.2 KB)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [August 28, 2017, 4:08pm UTC](https://forum.dynamobim.com/t/sort-revit-elements-by-number-then-letter/14305/17 "2017-08-28T16:08:49Z")

</div>

You need to sort them by letter then number.

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/b/bb4616f771e9f605253cc835501afcdfe31bbfcf.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:** [August 28, 2017, 4:23pm UTC](https://forum.dynamobim.com/t/sort-revit-elements-by-number-then-letter/14305/18 "2017-08-28T16:23:25Z")

</div>

> [@jay.polding](#):
>
> it is just a list of Strings and not a list of Elements

Elements are sorted. The strings only serve to demonstrate that.  
Note that the strings are parameters obtained from sorted elements.

The _sorted list_ output port on the last _SortByKey_ node in my graph gives you a list of sorted elements (You can flatten the list, if you want)

---

<div class="post-metadata">

**Author:** ![jay.polding](https://avatars.discourse-cdn.com/v4/letter/j/85e7bf/32.png) [@jay.polding](https://forum.dynamobim.com/u/jay.polding)\
**Post date:** [August 28, 2017, 4:27pm UTC](https://forum.dynamobim.com/t/sort-revit-elements-by-number-then-letter/14305/19 "2017-08-28T16:27:19Z")

</div>

Sorry about that, yes your method did Elements. Thank you!

---

<div class="post-metadata">

**Author:** ![jay.polding](https://avatars.discourse-cdn.com/v4/letter/j/85e7bf/32.png) [@jay.polding](https://forum.dynamobim.com/u/jay.polding)\
**Post date:** [August 28, 2017, 4:31pm UTC](https://forum.dynamobim.com/t/sort-revit-elements-by-number-then-letter/14305/20 "2017-08-28T16:31:36Z")

</div>

Question for you two, why would I need to sort by letter and then by number? Why would I get such a different result the other way?

[Next page](https://forum.dynamobim.com/t/sort-revit-elements-by-number-then-letter/14305.md?page=2)
