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

Android Java.Lang.RuntimeException : Unable to start activity Component Info -

c# - Sort XmlNodeList with a specific Node value -

actionscript 3 - Equivalent to moveReceived in ElectroServer 5 -