How to sort a string in python?
![](https://pythonpoint.net/wp-content/uploads/2020/11/How-to-create-matrix-in-python_-3-1024x576.jpg)
A collection of one or more characters put in single, double or triple quotes is known as string in python.
Here we’ll see how to sort a string.
We use sorted() function to sort the string.
e.g.,
a="Python Point" print(sorted(a))
![](https://pythonpoint.net/wp-content/uploads/2020/11/Screenshot-686-1024x414.png)
We can use join() and sorted() function both to sort the string.
e.g.,
a="Hello world" print(" ".join(sorted(a)))
![](https://pythonpoint.net/wp-content/uploads/2020/11/Screenshot-687-1024x404.png)
This is how we can sort a string in python.
Subscribe
Login
Please login to comment
0 Discussion