If you prepend leading zeros to the numbers, Python should be able to sort them properly.
E.g.:
my_list = sorted([str(i) for i in range(20)])
print(my_list) # wrong order

my_list = sorted(["{:04d}".format(i) for i in range(20)])
print(my_list) # right order