Get Largest 2 numbers from each list

Hi Dynamo Community,

Does anyone know how to get Largest 2 numbers from each list in a group?

I’m trying to make room rectangle boundaries, want to generate a room width and length no matter what shape the room is. Any thoughts?

Thank you!

What about List.Sort and then List.TakeItems?

4 Likes


@ycai9HR9Q , hi

for sure there is something smarter :wink:

2 Likes

Hello


cordially
christian.stan

1 Like

That’s the method I’d use. In a code block it’d be something like this:

DSCore.List.TakeItems(DSCore.List.Sort(lstOfNumbers),-2);

1 Like

Hello, how do you place the @L2 in designscript?

thanks in advance
Cordially
christian.stan

Try this: DSCore.List.TakeItems(DSCore.List.Sort(lstOfNumbers)@L2<1>,-2);

1 Like

hello, thanks, for providing the solution in the case of lists of lists.

Cordially
christian.stan