fork download
  1. import re
  2.  
  3. r = re.compile(r'\w*(\d+)\w*')
  4.  
  5. def sort_data(data):
  6. data_list = data.split()
  7. data_list.sort(key=r.findall)
  8. return ' '.join(data_list)
  9.  
  10. print(sort_data('is2 Thi1s T4est 3a'))
  11. print(sort_data('4of Fo1r pe6ople g3ood th5e the2'))
Success #stdin #stdout 0.02s 9448KB
stdin
Standard input is empty
stdout
Thi1s is2 3a T4est
Fo1r the2 g3ood 4of th5e pe6ople