- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to sort a list of strings in Python?
To sort a list in place, i.e., sort the list itself and change ordering in that list itself, you can use sort() on the list of strings. For example,
>>> a = ["Hello", "My", "Followers"] >>> a.sort() >>> print a ['Followers', 'Hello', 'My']
If you want to keep the original list intact and instead want a new list of the sorted elements, you can use sorted(list). For Example,
>>> a = ["Hello", "My", "Followers"] >>> b = sorted(a) >>> print b ['Followers', 'Hello', 'My']
- Python How to sort a list of strings
- Python program to Sort a List of Strings by the Number of Unique Characters
- How to remove empty strings from a list of strings in Python?
- Python – Sort by Rear Character in Strings List
- Python – Sort given list of strings by numeric part of string
- Convert list of strings to list of tuples in Python
- Convert list of tuples to list of strings in Python
- How to sort a Python date string list?
- Python program to sort a list of tuples alphabetically
- Python – Sort given list of strings by part the numeric part of string
- How to sort the objects in a list in Python?
- Python program to convert a list of strings with a delimiter to a list of tuple
- Python – To convert a list of strings with a delimiter to a list of tuple
- Convert list of strings and characters to list of characters in Python
- How to sort a list in C#?