Given a sentence, sort it alphabetically in ascending order.
Input : to learn programming refer geeksforgeeks Output : geeksforgeeks learn programming refer to Input : geeks for geeks Output : for geeks geeks
- Split the Sentence in words.
- Sort the words alphabetically
- Join the sorted words alphabetically to form a new Sentence.
Below is the implementation of above idea.
geeksforgeeks learn programming refer to for geeks geeks
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Sort the words in lexicographical order in Python
- Sort the given IP addresses in ascending order
- Sort an array of Roman Numerals in ascending order
- Sort an array of string of dates in ascending order
- Sort all even numbers in ascending order and then sort all odd numbers in descending order
- Sort an Array of dates in ascending order using Custom Comparator
- Sort first k values in ascending order and remaining n-k values in descending order
- Sort first half in ascending and second half in descending order | Set 2
- Sort first half in ascending and second half in descending order | 1
- Python | Check if given words appear together in a list of sentence
- Python | Spilt a sentence into list of words
- Python | Remove all duplicates words from a given sentence
- Python program to count words in a sentence
- Sorting rows of matrix in ascending order followed by columns in descending order
- Sorting rows of matrix in descending order followed by columns in ascending order
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.
Improved By : shubham_singh