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?

3 Answers 3


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)[0] # Assuming one data frame
group_lyr = [lyr for lyr in arcpy.mapping.ListLayers(mxd) if lyr.isGroupLayer][0] # 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)[0], "BEFORE")

arcpy.mapping.RemoveLayer(df, group_lyr)

Gist is here. I am using ArcGIS 10.3.1 for Desktop.

  • add those lines in the end of Cindy Williams code: mxd.save() del mxd
    – newGIS
    Dec 31, 2015 at 14:59
  • The abovementioned change is only required if the script is called programmatically on an existing mxd. The answer was written with the assumption that it will be run in the Python window in ArcMap. Jun 20, 2019 at 6:24
  • thanks Cidny, but i i run in external python file.
    – newGIS
    Jun 23, 2019 at 5:27

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).

  • Thanks. But I know the other sorting ways. Esri help describe that ways. But not my case what I need. How can I program it? I found something with PLTS but found nothing in that way. Thanks again for any advice.
    – Luis
    Dec 12, 2012 at 14:36

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

  • 1
    This looks like it is possible only when you have this extension, and not plain ArcMap. Jun 12, 2013 at 4:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.