mxd = arcpy.mapping.MapDocument("CURRENT") dfList = arcpy.mapping.ListDataFrames(mxd,"*") df = dfList[0] layerList = arcpy.mapping.ListLayers(mxd) layerList.sort() print str(len(layerList)) #print layerList for layer in layerList: print layer.name
Solved! Go to Solution.
import collections d = dict((x.name, x) for x in layers) od = collections.OrderedDict(sorted(d.items()))