private void quickSortPolynomial(int start, int end){
        int red = start - 1;
        int white = end + 1;
        int blue = end + 1;
        Term pivot = polynomial.get((start+end)/2);
        if(start < end){
            while(red < white - 1){
                Term t = polynomial.get(white - 1);
                if(t.power > pivot.power){
                    red++;
                    swapTerms(white - 1, red);
                }
                if(t.power == pivot.power){
                    white--;
                }
                if(t.power < pivot.power){
                    white--;
                    blue--;
                    swapTerms(white, blue);
                }
            }
            quickSortPolynomial(start, red);
            quickSortPolynomial(blue, end);
        }
    }