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
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Sort all even numbers in ascending order and then sort all odd numbers in descending order
- Sort first k values in ascending order and remaining n-k values in descending order
- 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
- Sort first half in ascending and second half in descending order | 1
- Sort first half in ascending and second half in descending order | Set 2
- Sort an array of string of dates in ascending order
- Sort an array of Roman Numerals in ascending order
- Sort an Array of dates in ascending order using Custom Comparator
- Sort the given IP addresses in ascending order
- Sort Matrix in alternating ascending and descending order rowwise
- Sort the words in lexicographical order in Python
- Print number in ascending order which contains 1, 2 and 3 in their digits.
- Sorting of Vector of Tuple in C++ (Ascending Order)
- Check if it is possible to rearrange rectangles in a non-ascending order of breadths
- Rearrange Odd and Even values in Alternate Fashion in Ascending Order
- Print 2-D co-ordinate points in ascending order followed by their frequencies
- Python | Remove all duplicates words from a given sentence
- Python program to count words in a sentence
- Python | Spilt a sentence into list of words
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