Ideas on how to sort a list in a better way

Hi everyone,

I am trying to sort my list in a way that gives me the desired outcome as you can see below:

Any ideas on how to achieve the desired outcome ?

Sorting List.dyn (91.3 KB)

You want the outcome be the same order as the desired one?

If you can accomplish this by putting in the correct order by list create?

hmmm so you want to sort your 4 lists based upon their first value?

@hugo.paalman @3Pinter

I want to sort them in ascending order based on their first index value. so ideally start with 0 and finish with 300

Hi
i hope this may be useful

Something like this?

This python should work:

# The inputs to this node will be stored as a list in the IN variables.
main = IN[0]

first = []
for vals in main:
    val = int(vals[0].split('-')[0])
    first.append(val)

sortlist = [x for _,x in sorted(zip(first,main))]

# Assign your output to the OUT variable.
OUT = sortlist

sortedpython

1 Like

@3Pinter @kennyb6

Thank you both. Both answers are really good :slight_smile: