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

php - Magento - Deleted Base url key -

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

javascript - Tooltipster plugin not firing jquery function when button or any click even occur -