      # Methods for sorting
      def sort_blur(self):
          """ Sort by blur amount """
          logger.info("Sorting by estimated image blur...")
          filename_list, image_list = self._get_images()
  
          logger.info("Estimating blur...")
          blurs = [self.estimate_blur(img) for img in image_list]
  
          logger.info("Sorting...")
          matched_list = list(zip(filename_list, blurs))
          img_list = sorted(matched_list, key=operator.itemgetter(1), reverse=True)
          return img_list
 
</s> remove         matched_list = list(zip(filename_list, blurs))
        img_list = sorted(matched_list, key=operator.itemgetter(1), reverse=True)
        return img_list
 </s> add         return sorted(blurs, key=lambda x: x[1], reverse=True) </s> remove         filename_list, image_list = self._get_images()
        distance = cv2.HISTCMP_BHATTACHARYYA
 </s> add  </s> remove         filename_list, image_list = self._get_images()
        scores = np.zeros(len(filename_list), dtype='float32')
        distance = cv2.HISTCMP_BHATTACHARYYA
 </s> add  </s> remove         logger.info("Calculating histograms...")
        histograms = [cv2.calcHist([img], [0], None, [256], [0, 256]) for img in image_list]
        img_list = list(zip(filename_list, histograms))
 </s> add         # TODO We have metadata here, so we can mask the face for hist sorting
        img_list = [(filename, cv2.calcHist([image], [0], None, [256], [0, 256]))
                    for filename, image, _ in tqdm(self._loader.load(),
                                                   desc="Calculating histograms",
                                                   total=self._loader.count,
                                                   leave=False)]
      # Methods for sorting
      def sort_blur(self):
          """ Sort by blur amount """
          logger.info("Sorting by estimated image blur...")




  
          logger.info("Sorting...")
          matched_list = list(zip(filename_list, blurs))
          img_list = sorted(matched_list, key=operator.itemgetter(1), reverse=True)
          return img_list
keep keep keep keep replace replace replace replace keep keep keep keep keep
 tools.sort
  - Add sort by size
  - Centralize some of the image loading routines 
tools/sort/sort.py