human
Python: sorting items in a dictionary by a part of a key?
assistant
Here is some code to sort items in dictionary `d`  using the first part of the key after splitting the key

sorted(list(d.items()), key=lambda name_num: (name_num[0].rsplit(None, 1)[0], name_num[1]))

#Warning: this code generation is experimental. Please inspect the code for any bugs before executing.