This is my code, I hope it helps you James Crandall
import arcpy
from collections import defaultdict
vector = 'yourShapefile.shp'
fields = ["glac_id", "FID", "SHAPE@LENGTH"]
selections = defaultdict(dict)
top3 = defaultdict(list)
with arcpy.da.SearchCursor(vector, fields) as cursor:
for row in cursor:
selections[row[0]][row[1]] = row[2]
for i in selections.keys():
top3[i] = sorted(selections[i], key=selections[i].get)[-3:]
The if I print top3, it will give me:
defaultdict(<type 'list'>, {u'G012161E78870N': [41, 46, 47], u'G011895E78886N': [5, 3, 18], u'G012039E78878N': [44, 42, 17]})
which are FIDs of 3 longest lines per area. Now all you have to do is extract lines by ID from original file (or do whatever you want).