How to sort Shape keys by "a to z" in blender 2.8?
I'm no expert in this area, but something along the lines of this script, executed on the current active object, in Object Mode ?

import bpy


ob = bpy.context.object
skeys = ob.data.shape_keys.key_blocks 

skey_names = sorted(skeys.keys(), key=lambda v: v.upper())

for name in skey_names:
    idx = skeys.keys().index(name)
    ob.active_shape_key_index = idx
    bpy.ops.object.shape_key_move(type='BOTTOM')


which works, but any edits to improve style are welcome. I can't help thinking I've handled that list in a clunky way.

EDIT in response to @lemon's comment:

The reason I thought this was clunky was that I thought there was no guarantee of the order of keys in a Python dictionary. But 1... that's not true, and 2... I don't think it matters anyway.


skey_names is just an independent alphabetically sorted list of strings; a snapshot of the dict-keys of the  bpy_prop_collection of shape keys. We are assuming the contents of original property-dictionary will not be modified before the loop terminates, but assume nothing about order .


For each of those sorted names, in order ...


... the ordinary Python dictionary call of .index(str) returns its position in the current state of the original property-dictionary, wherever it is ...
.. to be used to set the read/write .active_shape_key_index to make the shape key labeled by it active...
... so the context-sensitive bpy.ops.object.shape_key_move can send it to the bottom of the list, (preserving the order of the other items).


Sending each item to the bottom of the list in alphabetical order results in an alphabetically-sorted list