Minimum values of a list


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.


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


a python slice would do the trick.

# Load the Python Standard and DesignScript Libraries
import sys
import clr
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

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