Is this not an option? If you need to automate it, you can use the mapping module.
import arcpy
project = arcpy.mp.ArcGISProject("CURRENT")
for mp in project.listMaps():
# Sort Layers by Name
sorted_layers = sorted(mp.listLayers(), key=lambda lyr: lyr.name)
previous_layer = None
# Iterate through sorted layers and move them to the top of the map
for lyr in sorted_layers:
# Use existing first layer as reference for sorted first layer
if not previous_layer:
mp.moveLayer(mp.listLayers()[0], lyr, "BEFORE")
else:
mp.moveLayer(previous_layer, lyr, "AFTER")
previous_layer = lyr
If you have group layers and want to preserve internal group layer ordering, you will have to update the lyr.name sory key to lyr.longName so the group layer name is included in the sort.