Second and third minimum value of a sub-list

I want to get the index of the minimum and the second minimun and third minimum of a sub list.
So I have made this script which works well using a small list.

But as soon as I use a huge list (several thousands), it crashes…
Do you have any idea to make it more efficient ?

What is the next step in your process? Why do you need the indices and not just the values?

Honestly not very elegant …

1 Like

How about sorting list and then getting its 2nd and 3rd item by List.Slice?
If you need indices of the original list I’d then retrieve them with AllIndicesOf node:

It seems to be a bit shorter way to achieve what you want.

2 Likes

5 Likes

@Nick_Boyts
hi Nick, yes then i want the value, but first the item…
tkx for your script, that’s what i 'm looking for, but i can find the node “if equal return index” and my node list.takeitem don’t get any @ in it, how do I get it ?
:slight_smile:

Enable levels by clicking on the > to the right of the input.

Check out the list @ levels area of the dynamo primer for more info.

http://dynamoprimer.com/en/06_Designing-with-Lists/6-3_lists-of-lists.html

1 Like

tkx @JacobSmall but i don’t have any > right next to my input

What version of dynamo are you on?

0.9.1
@JacobSmall

Can you upgrade? Well worth it. Most documentation will be behind a bit otherwise and you’re missing out on some awesome features.

In the meantime, try setting lacing to longest and/or cross product on the nodes with levels enabled.

1 Like

If your end goal is the values you don’t necessarily need the indices. You could just sort the values themselves and take the first three values from each sublist.

@Nick_Boyts
in fact, I do need the indices first, what about the node “if equal return index” ?
Is it from a specific package ?

It’s from its own package. Just search for If Equal Return Index.

1 Like

@Pierre_MARECHAL Possible with OOTB nodes too.
Though not sure if SortByKey worked the same way in 0.9.1


Note the Lacing

2 Likes