def test_number_aware_alphabetical_key():
 l = ['0', 'mystr_1', 'mystr_10', 'mystr_2', 'mystr_1_a', 'mystr']
 l.sort(key=number_aware_alphabetical_key)
 print(l)
 assert (l == ['0', 'mystr', 'mystr_1', 'mystr_1_a', 'mystr_2', 'mystr_10'])

def test_number_aware_alphabetical_key ( ) : l = [ '0' , 'mystr_1' , 'mystr_10' , 'mystr_2' , 'mystr_1_a' , 'mystr' ] l . sort ( key = number_aware_alphabetical_key ) print ( l ) assert ( l == [ '0' , 'mystr' , 'mystr_1' , 'mystr_1_a' , 'mystr_2' , 'mystr_10' ] )
tests that number-aware sorting matches a manually generated output on a specific example .