code: def natural_sort(list, key=lambda s:s):
      def get_alphanum_key_func(key):
          convert = lambda text: int(text) if text.isdigit() else text
          return lambda s: [convert(c) for c in re.split('([0-9]+)', key(s))]
      sort_key = get_alphanum_key_func(key)
      list.sort(key=sort_key)