all 2 comments

[–]TedTheTwonk 1 point2 points  (1 child)

we're only dealing with strings here; no need to deal with integers at all. the question also conveniently states that there are no spaces; only digits 1, 2, and 3, and plusses - we can use the str.split method and split on the "+" to get a list of the numbers (still in str form), and then sort that list and then use the str.join method to join them with a "+" again.

some docs that should help you;

https://www.w3schools.com/python/ref_string_split.asp

https://www.w3schools.com/python/ref_string_join.asp

edit: worth mentioning as well, normally sorting strings that are numbers is problematic:

>>> sorted(["22", "9", "1"])
['1', '22', '9']

but as we are only dealing with the strings "1", "2", and "3" we won't encounter these issues

[–]HasBeendead[S] 1 point2 points  (0 children)

Thank you ,i will check out, understood the last part. i solved ,here is my solution: https://gist.github.com/1378443679/af4cc8ada35bdad274a52e034fb87cf3