code: private static int permParity(final ILigand[] ligands) {
  
          // count the number of swaps made by insertion sort - if duplicates
          // are fount the parity is 0
          int swaps = 0;
  
          for (int j = 1, hi = ligands.length; j < hi; j++) {
              ILigand ligand = ligands[j];
              int i = j - 1;
              int cmp = 0;
              while ((i >= 0) && (cmp = cipRule.compare(ligand, ligands[i])) > 0) {
                  ligands[i + 1] = ligands[i--];
                  swaps++;
              }
              if (cmp == 0) // identical entries
                  return 0;
              ligands[i + 1] = ligand;
          }
  
          // odd (-1) or even (+1)
          return (swaps & 0x1) == 0x1 ? -1 : +1;
      }
docs: Obtain the permutation parity (-1,0,+1) to put the ligands in descending
  order (highest first). A parity of 0 indicates two or more ligands were
  equivalent.
  
  @param ligands the ligands to sort
  @return parity, odd (-1), even (+1) or none (0)