I get a list of layers from ArcMap. If I sort the layer list, it doesn't seem to sort. Here's a snippet of the code I use.I attached a text file showing the results when I run the script from the python window in ArcMap. I also attached an image showing my table of contents with 219 layers.When I use the code in a script, the results are a lot worst then the results show.I'm using 10.1, sp1 on XP.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