0 votes
1 view
in Python by (14.2k points)

What is the best way of creating an alphabetically sorted list in Python?

1 Answer

0 votes
by (30.4k points)

The easiest way is to use sorted() function that sorts a list of string. The sorted() function modifies your original list to get a sorted copy of the list, without changing the original list below is an example that illustrates the use of shorted() function:-

mylist = ["a", "d", "B"]

for x in sorted(mylist):