code: public void sort() {
          PriorityQueue<Op.Pair<Term, Double>> termCentroids
                  = new PriorityQueue<Op.Pair<Term, Double>>(
                          terms.size(), new Ascending());
          Defuzzifier defuzzifier = new Centroid();
          for (Term term : terms) {
              double centroid;
              try {
                  if (term instanceof Constant || term instanceof Linear) {
                      centroid = term.membership(0);
                  } else {
                      centroid = defuzzifier.defuzzify(term, getMinimum(), getMaximum());
                  }
              } catch (Exception ex) {
                  centroid = Double.POSITIVE_INFINITY;
              }
              termCentroids.offer(new Op.Pair<Term, Double>(term, centroid));
          }
  
          List<Term> sortedTerms = new ArrayList<Term>(terms.size());
          while (!termCentroids.isEmpty()) {
              sortedTerms.add(termCentroids.poll().getFirst());
          }
          setTerms(sortedTerms);
      }
docs: Sorts the terms in ascending order according to their centroids