A small hack to do natural, numeric sort of string values in Python is to use the int
function when calling sorted (here, applied to a dictionary get it sorted by its keys):
for position in sorted(positions.keys(), key=int):
This will call int(