How to sort an array(a list) of strings in lexicographical (dictionary, alphabetical) order in Python

1 Answer

0 votes
lst = ['python', 'c', 'java', 'c++', 'php', 'c#']


lst = sorted(lst)


for item in lst:
    print(item, end=" ")

 
'''
run:
 
c c# c++ java php python
 
'''

 



answered Jun 3, 2017 by avibootz
...