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

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

1 Answer

0 votes
by (107k 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):

   print(x)

image

Related questions

0 votes
1 answer
0 votes
2 answers
asked Jul 22 in Python by Sammy (47.7k points)
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...