Python Practice › String Programs › Program 57
Sort the characters of a string
Write a Python program to sort the characters of a string.
Input
"xyabkmp"
Output
abkmpxy
Approach
sorted()returns a list of characters; join it.
Solution
print("".join(sorted("xyabkmp")))Output
abkmpxy
Learn the concept
New to this topic? Read the lesson, then come back.