Given a string of letters, write a python program to sort the given string in an alphabetical order.
Input : PYTHON Output : HNOPTY Input : Geeks Output : eeGks
When string is in same case –
Method #1 : Using
Method #2 : Using
Method #3 : Using
Another alternative is to use reduce() method. It applies a join function on the sorted list using ‘+’ operator.
When string is in different cases –
- Python | Sort the items alphabetically from given dictionary
- Python | Sort the list alphabetically in a dictionary
- Python program to sort a list of tuples alphabetically
- Python | First N letters string construction
- Python | Insert value after each k letters in given list of string
- Python | Ways to split a string in different ways
- Python | Ways to sort list of float values
- Python | Ways to sort a zipped list by values
- Ways to sort list of dictionaries by values in Python – Using itemgetter
- Python | Ways to sort list of strings in case-insensitive manner
- Ways to sort list of dictionaries by values in Python - Using lambda function
- Reverse string in Python (5 different ways)
- Python | Sort each String in String list
- Python | Ways to check string contain all same characters
- Find length of a string in python (4 ways)
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.