Java Array Sort Sort(float cais[])

Here you can find the source of Sort(float cais[])

Description

Sort

License

LGPL

Declaration

public static int[] Sort(float cais[]) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    public static int[] Sort(float cais[]) {
        int res[] = new int[cais.length];
        for (int i = 0; i < res.length; i++)
            res[i] = i;//w w  w. j a v a2 s .  c  o  m

        int i, j, k, inc, n = cais.length;
        float v;

        inc = 1;
        do {
            inc *= 3;
            inc++;
        } while (inc <= n);

        do {
            inc /= 3;
            for (i = inc + 1; i <= n; i++) {
                v = cais[res[i - 1]];
                j = i;
                k = res[i - 1];
                while (cais[res[j - inc - 1]] < v) {
                    //cais[j]=cais[j-inc];
                    res[j - 1] = res[j - inc - 1];
                    j -= inc;
                    if (j <= inc)
                        break;
                }
                //cais[j]=v;
                res[j - 1] = k;
            }
        } while (inc > 0);

        return res;
    }
}

Related

  1. sort(double[] x)
  2. sort(E[] x, int[] w)
  3. sort(final double[] data)
  4. sort(final int[] data)
  5. sort(final long[] primary, final double[] secondary)
  6. sort(int v[], int left, int right)
  7. sort(int values[])
  8. sort(int[] array)
  9. sort(int[] array)