Python Practice › String Programs › Program 57

Sort the characters of a string

EasyString Programs · 57 of 106

Write a Python program to sort the characters of a string.

Advertisement
Input
"xyabkmp"
Output
abkmpxy

Approach

  1. sorted() returns a list of characters; join it.

Solution

Python
print("".join(sorted("xyabkmp")))
Output
abkmpxy

Learn the concept

New to this topic? Read the lesson, then come back.

More string programs

← All 106 String Programs

Leave a Comment