In this article, we will sort the lists by name, we will also reverse it.

let's get started

1. sorting a list by name


 #syntax
 list.sort()   

example:


list_a =  ['cat', 'table', 'apple', 'dog']
list_a.sort()
print(list_a)

Output:

['apple', 'cat', 'dog', 'table']

2. Reversing a list in python

In this part of the article, we'll reverse a list by using "reverse()" method


#syntax
list.reverse()   

example:


list_a =  ['cat', 'table', 'apple', 'dog']
list_a.reverse()
print(list_a)

Output :

['table', 'cat', 'dog', 'apple']

sorting and reversing a list at the same time

Syntax:


list.sort(reverse=True|False)

example:


list_a =  ['cat', 'table', 'apple', 'dog']
list_a.sort(reverse=True)
print(list_a)

output:

['table', 'dog', 'cat', 'apple']

I hope you've enjoyed with this article

see you later!

English today is not an art to be mastered it's just a tool to use to get a result