          but found in new_vals_list.
  
          Format of lists: [[img_path, value], [img_path2, value2], ...]
  
          :param sorted_list: list that has been sorted by one of the sort
          methods.
          :param new_vals_list: list that has been loaded by a different method
          than the sorted_list.
          :return: list that is sorted in the same way as the input sorted list
          but the values corresponding to each image are from new_vals_list.
          """
          new_list = []
          # Make new list of just image paths to serve as an index
          val_index_list = [i[0] for i in new_vals_list]
          for i in tqdm(range(len(sorted_list)), desc="Splicing", file=sys.stdout):
              current_img = sorted_list[i] if isinstance(sorted_list[i], str) else sorted_list[i][0]
              new_val_index = val_index_list.index(current_img)
              new_list.append([current_img, new_vals_list[new_val_index][1]])
  
          return new_list
  
      @staticmethod
      def find_images(input_dir):
          """ Return list of images at specified location """
          result = []
 
</s> remove             operation = 'ijk, kl -> ijl' if method.endswith('gray') else 'ijl, kl -> ijk'
            path = np.einsum_path(operation, imgs[0][..., :3], conversion, optimize='optimal')[0]

        progress_bar = tqdm(imgs, desc="Converting", file=sys.stdout)
        images = [np.einsum(operation, img[..., :3], conversion, optimize=path).astype('float32')
                  for img in progress_bar]
        return images

    @staticmethod
    def splice_lists(sorted_list, new_vals_list):
        """
        This method replaces the value at index 1 in each sub-list in the
        sorted_list with the value that is calculated for the same img_path,
        but found in new_vals_list.

        Format of lists: [[img_path, value], [img_path2, value2], ...]
 </s> add             self._output_non_grouped() </s> remove     @staticmethod
    def find_images(input_dir):
        """ Return list of images at specified location """
        result = []
        extensions = [".jpg", ".png", ".jpeg"]
        for root, _, files in os.walk(input_dir):
            for file in files:
                if os.path.splitext(file)[1].lower() in extensions:
                    result.append(os.path.join(root, file))
            break
        return result
 </s> add         logger.info("Done.") </s> remove     def reload_images(self, group_method, img_list):
        """
        Reloads the image list by replacing the comparative values with those
        that the chosen grouping method expects.
        :param group_method: str name of the grouping method that will be used.
        :param img_list: image list that has been sorted by one of the sort
        methods.
        :return: img_list but with the comparative values that the chosen
        grouping method expects.
        """
        logger.info("Preparing to group...")
        if group_method == 'group_blur':
            filename_list, image_list = self._get_images()
            blurs = [self.estimate_blur(img) for img in image_list]
            temp_list = list(zip(filename_list, blurs))
        elif group_method == 'group_blur_fft':
            filename_list, image_list = self._get_images()
            fft_blurs = [self.estimate_blur_fft(img) for img in image_list]
            temp_list = list(zip(filename_list, fft_blurs))
        elif group_method == 'group_face_cnn':
            filename_list, image_list, landmarks = self._get_landmarks()
            temp_list = list(zip(filename_list, landmarks))
        elif group_method == 'group_face_yaw':
            filename_list, image_list, landmarks = self._get_landmarks()
            yaws = [self.calc_landmarks_face_yaw(mark) for mark in landmarks]
            temp_list = list(zip(filename_list, yaws))
        elif group_method == 'group_hist':
            filename_list, image_list = self._get_images()
            histograms = [cv2.calcHist([img], [0], None, [256], [0, 256]) for img in image_list]
            temp_list = list(zip(filename_list, histograms))
        elif group_method == 'group_black_pixels':
            filename_list, image_list = self._get_images()
            black_pixels = [np.ndarray.all(img == [0, 0, 0], axis=2).sum()/img.size*100*3
                            for img in image_list]
            temp_list = list(zip(filename_list, black_pixels))
        else:
            raise ValueError(f"{group_method} group_method not found.")

        return self.splice_lists(img_list, temp_list)

    @staticmethod
    def _near_split(bin_range, num_bins):
        """ Obtain the split for the given number of bins for the given range

        Parameters
        ----------
        bin_range: int
            The range of data to separate into bins
        num_bins: int
            The number of bins to create
 </s> add     def process(self) -> None:
        """ Main processing function of the sort tool </s> remove         logger.info("Grouping by percentage of black pixels...")

        # Starting the binning process
        bins = [[] for _ in range(self._args.num_bins)]
        # Get edges of bins from 0 to 100
        bins_edges = self._near_split(100, self._args.num_bins)
        # Get the proper bin number for each img order
        img_bins = np.digitize([x[1] for x in img_list], bins_edges, right=True)

        # Place imgs in bins
        for idx, _bin in enumerate(img_bins):
            bins[_bin].append(img_list[idx][0])

        return bins

    def group_hist(self, img_list):
        """ Group into bins by histogram """
        logger.info("Grouping by histogram...")

        # Groups are of the form: group_num -> reference histogram
        reference_groups = {}

        # Bins array, where index is the group number and value is
        # an array containing the file paths to the images in that group
        bins = []

        min_threshold = self._args.min_threshold

        img_list_len = len(img_list)
        reference_groups[0] = [img_list[0][1]]
        bins.append([img_list[0][0]])

        for i in tqdm(range(1, img_list_len),
                      desc="Grouping",
                      file=sys.stdout):
            current_best = [-1, float("inf")]
            for key, value in reference_groups.items():
                score = self.get_avg_score_hist(img_list[i][1], value)
                if score < current_best[1]:
                    current_best[0], current_best[1] = key, score

            if current_best[1] < min_threshold:
                reference_groups[current_best[0]].append(img_list[i][1])
                bins[current_best[0]].append(img_list[i][0])
            else:
                reference_groups[len(reference_groups)] = [img_list[i][1]]
                bins.append([img_list[i][0]])
 </s> add         sort_method = self._args.sort_method
        group_method = self._args.group_method </s> remove         argument_list = list()
 </s> add         argument_list = []
        if self._args.log_changes:
            self._write_to_log(self._changes)
          but found in new_vals_list.
  
          Format of lists: [[img_path, value], [img_path2, value2], ...]
  
        if self._args.log_changes:
            self._write_to_log(self._changes)
        if self._args.log_changes:
            self._write_to_log(self._changes)
        if self._args.log_changes:
            self._write_to_log(self._changes)
        if self._args.log_changes:
            self._write_to_log(self._changes)
        if self._args.log_changes:
            self._write_to_log(self._changes)
        if self._args.log_changes:
            self._write_to_log(self._changes)
        if self._args.log_changes:
            self._write_to_log(self._changes)
        if self._args.log_changes:
            self._write_to_log(self._changes)
        if self._args.log_changes:
            self._write_to_log(self._changes)
        if self._args.log_changes:
            self._write_to_log(self._changes)
        if self._args.log_changes:
            self._write_to_log(self._changes)
        if self._args.log_changes:
            self._write_to_log(self._changes)
        if self._args.log_changes:
            self._write_to_log(self._changes)
        if self._args.log_changes:
            self._write_to_log(self._changes)
        if self._args.log_changes:
            self._write_to_log(self._changes)
        if self._args.log_changes:
            self._write_to_log(self._changes)
  
      @staticmethod
      def find_images(input_dir):
          """ Return list of images at specified location """
          result = []
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Overhaul sort:
  - Standardize image data reading and writing
  - Optimize loading (just one pass required)
  - Make all sort groups binnable (to greater or lesser results)
  - Add sort by pitch
  - Deprecate multiple options
  - linting, docs + locales 
tools/sort/sort.py