def _sorted_columns_from_metadata(metadata):
  """Sort metadata columns by name to ensure the order is consistent."""
  columns = metadata.get('columns', {})
  return sorted(columns.itervalues(), key=lambda value: value['name'])