def export_paths(glob_pattern, regex_pattern):
  """Gets a list of exported paths, ordered by timestamp (ascending).

  The two patterns are necessary since glob doesn't support general regexes that
  are required for stricter matches that avoid temporary files.

  Args:
    glob_pattern (string): Input to tf.gfile.Glob.
    regex_pattern (string): Regular expression for additional filtering. This
      should have a match group named "timestamp".

  Returns:
    Filenames sorted by timestamp (later paths at the end).
  """
  matcher = re.compile(regex_pattern)
  filtered_exports = []  # (int timestamp, string path) pairs

  for filename in tf.gfile.Glob(glob_pattern):
    match = matcher.match(filename)
    if match:
      # Gets the timestamp as an integer, instead of comparing it lexically.
      timestamp = int(match.groupdict().get("timestamp", "0"))
      filtered_exports.append((timestamp, filename))

  return [filename for timestamp, filename in sorted(filtered_exports)]
Gets a list of exported paths, ordered by timestamp (ascending).

  The two patterns are necessary since glob doesn't support general regexes that
  are required for stricter matches that avoid temporary files.

  Args:
    glob_pattern (string): Input to tf.gfile.Glob.
    regex_pattern (string): Regular expression for additional filtering. This
      should have a match group named "timestamp".

  Returns:
    Filenames sorted by timestamp (later paths at the end).
  
language/common/utils/export_utils.py