tosink

Sorting Algorithms For Integer & Alphabet

Nov 15th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. list_string =  raw_input("")
  2. list_int, list_str, list_new, str_counter, int_counter = [],[],[],0,0
  3.  
  4. for i in list_string.split():
  5.     ord_code = ord(i[0])
  6.     if ord_code >= 97 and ord_code <= 122:
  7.         list_str.append(i)
  8.     else:
  9.         list_int.append(int(i))
  10.  
  11. list_str.sort()
  12. list_int.sort()        
  13.  
  14. for i in list_string.split():
  15.     ord_code = ord(i[0])
  16.     if ord_code >= 97 and  ord_code <= 122:
  17.         list_new.append(list_str[str_counter])
  18.         str_counter+=1
  19.     else:
  20.         list_new.append(list_int[int_counter])
  21.         int_counter+=1
  22.  
  23. print " ".join(map(str, (list_new)))
Add Comment
Please, Sign In to add comment