(* Sorting list of plants *) maintainSort := ( monocots = { "Arecaceae", "Commelinaceae", "Cymodoceaceae", "Cyperaceae", "Hydrocharitaceae", "Juncaceae", "Liliaceae", "Poaceae", "Xanthorrhoeaceae", "Ruppiaceae", "Potamogetonaceae" }; listsort = Table[ name = data[[1]]; g = plantclass[name]; g = If[! StringFreeQ[g, "Gymnosper"], 0, 1, 1]; If[MemberQ[monocots, plantfamily[name]], g = 2]; {g, plantfamily[name], plantgenus[name], name}, {data, datalist}]; listsort = Sort[listsort]; Print["Sorted list: ", listsort // TableForm]; plantlist = #[[4]]& /@ listsort; plantfamilies = DeleteDuplicates[#[[2]] & /@ listsort]; plantlista = Sort[plantlist]; );