code: def get_tdata(t_format, files):
      def median(arr):
          return arr.min() + (arr.max() - arr.min())/2
      import re
      from pandas import Index
      t_pattern = t_format
      for fmt, patt in t_patterns.items():
          t_pattern = t_pattern.replace(fmt, patt)
      t_pattern = re.compile(t_pattern)
      time = list(range(len(files)))
      for i, f in enumerate(files):
          time[i] = median(np.array(list(map(
              lambda s: np.datetime64(dt.datetime.strptime(s, t_format)),
              t_pattern.findall(f)))))
      ind = np.argsort(time)
      files = np.array(files)[ind]
      time = np.array(time)[ind]
      return to_datetime(Index(time, name='time')), files