code: private int permutationParity(int[] vs) {
          int n = 0;
          for (int i = 0; i < vs.length; i++)
              for (int j = i + 1; j < vs.length; j++)
                  if (vs[i] > vs[j]) n++;
          return (n & 0x1) == 1 ? -1 : 1;
      }
docs: Compute the permutation parity of the values {@code vs}. The parity is
  whether we need to do an odd or even number of swaps to put the values in
  sorted order.
  
  @param vs values
  @return parity of the permutation (odd = -1, even = +1)