Advertisement
Guest User

gggfgf

a guest
Jan 21st, 2020
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. def sort_str(string_1):
  2. count=0
  3. s=string_1[0]
  4. new_str=""
  5. if len(string_1) != 1:
  6. while count==0:
  7. for i in range(len(string_1)):
  8. if ord(string_1[i])<ord(s):
  9. s = string_1[i]
  10. index_char = i
  11. str1 = sort_str(string_1[0:index_char])
  12. str2 = string_1[index_char+1:]
  13. new_str = str1+str2
  14. count+=1
  15. return new_str+s
  16. else:
  17. return string_1
  18. print("Please enter a string to sort: ")
  19. s = input()
  20. print(f"The string to sort is:{s}")
  21. print(f"The sorted string is:{sort_str(s)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement