public static void sort(List<Integer> list) {
        int n = list.size();
        int h = 1;
        while (h < n / 3) {
            h = 3 * h + 1;
        }

        while (h >= 1) {

            for (int i = h; i < n; i++) {

                for (int j = i; j >= h && list.get(j) < list.get(j - h); j -= h) {
                    Integer tmp = list.get(j);
                    list.set(j, list.get(j - h));
                    list.set(j - h, tmp);
                }

            }
            h = h / 3;
        }
    }