code: public static void sortBy(MutableFst fst, Comparator<Arc> comparator) {
      int numStates = fst.getStateCount();
      for (int i = 0; i < numStates; i++) {
        MutableState s = fst.getState(i);
        s.arcSort(comparator);
      }
    }
docs: Applies the ArcSort on the provided fst. Sorting can be applied either on input or output label based on the
  provided comparator.
  
  @param fst the fst to sort it's arcs
  @param comparator the provided Comparator