Minimum values of a list

Hello,

I’d like to know is it possible to find the minimum two values from a list. I know I can use minimum item, filter by pool mask twice. But, i’d like to reduce the script as much as possible.

Thanks

List.Sort and List.TakeItems should do the trick.

Thanks for the reply.

I’ve thought about this solution. The trouble is, you have to specify the exact minimum value in takeitems. I need a more general script, to take the minimum two values no matter what they are.

Use a sort and a count node
Take the value of “Count” to select the last item

2 Likes

a python slice would do the trick.

# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

# Place your code below this line
val=IN[0]

# Assign your output to the OUT variable.
OUT =sorted(val)[:2]