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

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

php - Magento - Deleted Base url key -

symfony - imagine_filter() not generating the correct url in LiipImagineBundle -