Here an other way.
Simple yet flexible natural sorting in Python
>>> my_list = ['Name_1', 'Name_10', 'Name_2', 'Name_20', 'Name_3', 'Name_32'] >>> sorted(my_list, key=lambda w: int(w[5:])) ['Name_1', 'Name_2', 'Name_3', 'Name_10', 'Name_20', 'Name_32']The problem is often called Human or Natural sorting,then there is of course made solution for this.
Simple yet flexible natural sorting in Python
>>> from natsort import natsorted >>> >>> my_list = ['Name_1', 'Name_10', 'Name_2', 'Name_20', 'Name_3', 'Name_32'] >>> natsorted(my_list) ['Name_1', 'Name_2', 'Name_3', 'Name_10', 'Name_20', 'Name_32']