Given a list of strings, the task is to sort that list based on given requirement.
There are multiple scenarios possible while sorting a list of sting, like –
- Sorting in alphabetical/reverse order.
- Based on length of string character
- Sorting the integer values in list of string etc.
Let’s discuss various ways to perform this task.
Example #1: Using
['a', 'for', 'geeks', 'gfg', 'is', 'portal']
Example #2: Using
a for geeks gfg is portal
Example #3: Sort by length of strings
['a', 'is', 'for', 'geeks', 'portal', 'Geeksforgeeks']
Example #4: Sort string by integer value
['7', '11', '23', '33', '55']
Example #5: Sort in descending order
['portal', 'is', 'gfg', 'geeks', 'for', 'a']
- Python | Sort list of dates given as strings
- Sort numeric strings in a list in Python
- Python | Sort all sublists in given list of strings
- Python | Sort given list of strings by part of string
- Python | Ways to sort list of strings in case-insensitive manner
- Python | Remove empty strings from list of strings
- Python | Tokenizing strings in list of strings
- Python | Sort the values of first list using second list
- Python | Sort list of list by specified index
- Python | Sort list according to other list order
- Python | Sort Flatten list of list
- Python - Sort dictionaries list by Key's Value list index
- Python | Filter a list based on the given list of strings
- Python | Convert list of strings and characters to list of characters
- Python | Convert list of tuples to list of strings
- Python | Convert list of strings to list of tuples
- Python | Filter list of strings based on the substring list
- Python | Merge list of tuple into list by joining the strings
- Python | Convert List of lists to list of Strings
- Python Program for Odd-Even Sort / Brick Sort
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.