I have some 100 features in my ArcMap Project. I choose at TOC the View mode "List by drawing order". How can I sort this list ascending or by name alphbetical? Under the options field, is nothing like this. The drawing order should be ascending by name. Or how can I sort them on other way?
I wrote a script using MoveLayer and a temporary Group Layer to get this to work. First create a new group layer anywhere in your TOC (it doesn't matter what it's called, it will be deleted at the end). This only works based on the assumption that this temporary group layer is the only one in the mxd. Of course, this can be bypassed by giving your temporary layer a constant name (such as "TempGroup"), and changing the script to use that group layer specifically for the sorting.
mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd) # Assuming one data frame group_lyr = [lyr for lyr in arcpy.mapping.ListLayers(mxd) if lyr.isGroupLayer] # The temp group layer should be the only one lyr_names = sorted(lyr.name for lyr in arcpy.mapping.ListLayers(mxd) if lyr.isFeatureLayer) for name in lyr_names: arcpy.mapping.MoveLayer(df, group_lyr, arcpy.mapping.ListLayers(mxd, name), "BEFORE") arcpy.mapping.RemoveLayer(df, group_lyr)
Gist is here. I am using ArcGIS 10.3.1 for Desktop.
There is no way to sort the List By Drawing Order TOC (without programming).
But it is possible to sort the List By Visibility TOC and the Listing by selection TOC: Go to the option button on the TOC. On the Preferences tab chose whether to sort layers by the order they are drawn or alphabetically by layer name (Sort layers by).
yes you can do it
Sorting the table of contents in alphabetical order, please find detail in: http://resources.arcgis.com/en/help/main/10.1/index.html#//0106000001qt000000