def sort_files(files):
  """Returns a sorted version of the given list of File's (or other structures
  that define an 'id' data member). The files will be sorted according to their
  id, and duplicate entries will be removed.

  Parameters
  ----------
  files : list of :py:class:`bob.db.base.File`
      The list of files to be uniquified and sorted.

  Returns
  -------
  sorted : list of :py:class:`bob.db.base.File`
      The sorted list of files, with duplicate `BioFile.id`\s being removed.
  """
  # sort files using their sort function
  sorted_files = sorted(files)
  # remove duplicates
  return [f for i, f in enumerate(sorted_files) if
          not i or sorted_files[i - 1].id != f.id]