sorting - How do I sort a string in alphabetical order in Python? -


i know there sort function:

>>> = 'bags' >>> ''.join(sorted(a)) 'abgs' 

however, need write mine scratch. think use mergesort i'm not sure how work string in python. e.g., can compare characters? can find middle of string somehow?

i'm using python 3.4.

yes compare characters.

b > evaluates true in python, , forth.

you first convert string list, , it's middle via length, sequential comparison , join sorted list sorted string.


Comments

Popular posts from this blog

c++11 - Intel compiler and "cannot have an in-class initializer" when using constexpr -

rest - Spring boot: Request method 'PUT' not supported -

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -