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 list alphabetically in a dictionary
- Python | First N letters string construction
- Python | Insert value after each k letters in given list of string
- 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
- Ways to sort list of dictionaries by values in Python - Using lambda function
- Reverse string in Python (5 different ways)
- Ways to remove i'th character from string in Python
- Find length of a string in python (4 ways)
- Python | Ways to remove n characters from start of given string
- Python | Ways to remove numeric digits from given string
- Python | Ways to convert string to json object
- Python program to sort a string
- Python | Sort given list of strings by part of string
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.