How about something along these lines?
import bpy scn = bpy.context.scene cols = scn.collection.children sorted_cols = sorted (cols, key = lambda c: c.name.lower()) for col in sorted_cols: dup = col cols.unlink(col) cols.link(dupcol) There may be problems with it.. I haven't covered all the bases, and you may want to do it recursively, etc..?