private int med3(List<T> x, int a, int b, int c) {
            return (comparator.compare(x.get(a), x.get(b)) < 0 ?
                    (comparator.compare(x.get(b), x.get(c)) < 0 ? b : comparator.compare(x.get(a), x.get(c)) < 0 ? c : a) :
                    (comparator.compare(x.get(b), x.get(c)) > 0 ? b : comparator.compare(x.get(a), x.get(c)) > 0 ? c : a));
        }