def numsplit(text):
 result = []
 for group in re.split('(\\d+)', text):
  if group:
   try:
    group = int(group)
   except ValueError:
    pass
   result.append(group)
 return result

def numsplit ( text ) : result = [ ] for group in re . split ( '(\\d+)' , text ) : if group : try : group = int ( group ) except ValueError : pass result . append ( group ) return result
convert string into a list of texts and numbers in order to support a natural sorting .