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
Post a Comment