code: def _sorter(generated):
      pairs = [(os.path.dirname(f), os.path.basename(f))
               for f in set(list(generated))]
      pairs.sort()
      return [os.path.join(pair[0], pair[1]) for pair in pairs]