Here is a small sample of one way to do thisâ€¦ There are comments in the script.

The principle I used here is a little trick, that in python you can sort nested lists (lists inside of lists), it will sort by the first element inside each nested list or tuple. So I first got all the curve idâ€™s, then created a nested list of tuples of the each curveâ€™s length paired with its id. The lengths are gotten with rs.CurveLength().

I then sort that nested list by biggest first, and retrieve the desired number of longest curves at the end from the sorted list, starting at the beginning of the list.

```
import rhinoscriptsyntax as rs
#user selects a collection of curves
crvs=rs.GetObjects("Select some curves",4,preselect=True)
if crvs:
#ask the user how many of the longest curves they want to select
msg="How many of the longest curves to select?"
count=rs.GetInteger(msg,minimum=1,maximum=len(crvs))
if count:
#create a nested list of tuples of (curve length,curve id) for all curves
crv_info=[(rs.CurveLength(crv_id),crv_id) for crv_id in crvs]
#sort the nested list by the length, biggest first (reverse=True)
#if you want the shortest, leave out the reverse=True
crv_info.sort(reverse=True)
#get the desired number of longest curves, from beginning of sorted list
for i in range(count):
#select the curve ID's which are in index 1 of each tuple
rs.SelectObject(crv_info[i][1])
#print the curve length for reference
print "Curve {} length: {}".format(i+1,crv_info[i][0])
```

Let me know if this stuff makes sense and if not, donâ€™t hesitate to ask questionsâ€¦

â€“Mitch