This post will discuss how to sort a list of strings in Python.

1. Using sort() function

The standard solution to sort a list of strings in Python is using the sort() function. This function sorts the list in-place and results in a stable sort.

Download  Run Code

 
The sort() function accepts the reverse argument, which takes a boolean value. When true, the list is sorted in reverse order.

Download  Run Code

2. Using sorted() function

The list.sort() function modifies the original list as it uses an in-place sorting algorithm. To get a new, sorted copy of a list without changing the original list, use the sorted() built-in function.

Download  Run Code

 
To sort a list in reverse order, specify the reverse argument as True.

Download  Run Code

That’s all about sorting a list of strings in Python.