code: def _frequency_order_transform(sets):
      
      logging.debug("Applying frequency order transform on tokens...")
      counts = reversed(Counter(token for s in sets for token in s).most_common())
      order = dict((token, i) for i, (token, _) in enumerate(counts))
      sets = [np.sort([order[token] for token in s]) for s in sets]
      logging.debug("Done applying frequency order.")
      return sets, order
docs: Transform tokens to integers according to global frequency order.
      This step replaces all original tokens in the sets with integers, and
      helps to speed up subsequent prefix filtering and similarity computation.
      See Section 4.3.2 in the paper "A Primitive Operator for Similarity Joins
      in Data Cleaning" by Chaudhuri et al..
  
      Args:
          sets (list): a list of sets, each entry is an iterable representing a
              set.
  
      Returns:
          sets (list): a list of sets, each entry is a sorted Numpy array with
              integer tokens replacing the tokens in the original set.
          order (dict): a dictionary that maps token to its integer representation
              in the frequency order.