View Discussion
Improve Article
Save Article
View Discussion
Improve Article
Save Article
Given a string of letters, write a python program to sort the given string in an alphabetical order.
Example:
Input : PYTHON Output : HNOPTY Input : Geeks Output : eeGks
Naive Method to sort letters of string alphabetically
Here we are converting the string into list and then finally sorting the entire list alphabet wise.
Python3
s
=
"GEEKSFORGEEKS"
li
=
[]
l
=
len
[s]
for
i
in
range
[
0
,l]:
li.append[s[i]]
for
i
in
range
[
0
,l]:
for
j
in
range
[
0
,l]:
if
li[i]