if (comparator.compare(S[i], S[j]) < 0) {
            results[results.length - k] = i;
            k--;
          }