I’m working on a graph that will pull property set data from autocad objects and output to excel. I’ve successfully pulled the data, but I would like to sort the data based on multiple parameters. I would like to have sub list entry 0 be sorted, then entry 1, 2,3,4, 5, but I’m not sure how to get Dynamo to subsort that many parameters. Any advice would be helpful.
It’s very common to sort by multiple parameters but the more you sort by the more list levels you have to deal with. This isn’t hard, but it can get messy if you’re not super comfortable with list levels yet.
The easiest thing to do is just combine values. Rather than sorting by one value, then a second, then a third, and so on… just concatenate all your values into a single string then use SortByKey to sort the sublists by that value.
Just keep in mind that numeric values will sort by character instead of by value this way. You can either break up your parameters to handle numbers and strings separately or you can pad your numeric values so they sort “correctly”.
Thanks @Nick_Boyts for the reply, but I don’t think that will give the outcome I’m looking for. In your example, I would like it to be sorted like this:
0Ca
0Eb
1Ac
1Ba
2Ac
2Fc
So all the elements in level 1 index 0 are sorted, then level 1 index 1, then index 2 etc. Kind of like how in Excel you can sort by a parameter, then sort by another parameter.
Let me know if I’ve just confused things more.
I don’t think this will work if the items are of different lengths, e.g. [0, A, E] and [0, DEF, G]/ as seen in the image by JBroad. Haven’t tested it though.
I think the Python approach by @Giovanni_Brogiolo is the way to go.
Good callout. This would require padding just like natural sorting of numeric strings. Python is definitely the easiest and shortest fix, however there are tons of ways to solve this problem with out of the box nodes and a little logical thinking.
@Nick_Boyts I didn’t see all the output but looks like you got a solution. I don’t have time to test right now, but it looks like Python will be the easiest. I’ll have to figure out how to feed it the criteria by which I want the data sorted because it won’t all be numerical or alphabetical.



