I have created a python script for dual sorting, it needs to sort by one first condition then do a secondary sort without effecting the arrangement of the primary sort condition.
The issue i am having is that it doesnt always sort correctly on the secondary sort which you will be able to see on the image and the python code is below.
Image link as i couldnt upload to here(will change later):
Any advice or help would be greatful as this is my first python code.
[quote]
<span style=“color: #f92672; font-weight: bold;”>import</span> clr
clr.<span style=“color: #ffffff; font-weight: bold;”>AddReference</span>(<span style=“color: #e6db74;”>‘ProtoGeometry’</span>)
<span style=“color: #f92672; font-weight: bold;”>from</span> Autodesk.DesignScript.Geometry <span style=“color: #f92672; font-weight: bold;”>import</span> *
<span style=“color: #75715e;”>#The inputs to this node will be stored as a list in the IN variable.</span>
list_el = IN[<span style=“color: #ae81ff;”>0</span>]
orientation = IN[<span style=“color: #ae81ff;”>1</span>]
output = []
<span style=“color: #f92672; font-weight: bold;”>if</span> orientation == True:
output = <span style=“color: #ffffff; font-weight: bold;”>sorted</span>(list_el, key=<span style=“color: #f92672; font-weight: bold;”>lambda</span> list_el:(list_el[<span style=“color: #ae81ff;”>1</span>], -list_el[<span style=“color: #ae81ff;”>2</span>]), reverse=True)
<span style=“color: #f92672; font-weight: bold;”>else</span>:
output = <span style=“color: #ffffff; font-weight: bold;”>sorted</span>(list_el, key=<span style=“color: #f92672; font-weight: bold;”>lambda</span> list_el:(list_el[<span style=“color: #ae81ff;”>2</span>], list_el[<span style=“color: #ae81ff;”>1</span>]))
<span style=“color: #75715e;”>#Assign your output to the OUT variable</span>
OUT = output
[quote]