code: public static <T> Iterable<PSArray<T>> create(Iterable<T> items, final Comparator<T> comparator) {
          MutableArray<T> initial = MutableArrayFromIterable.create(items);
          GoodSortingAlgorithm.getInstance().sort(initial, comparator);
          return IterableUsingStatusUpdater.create(initial, new Updater<PSArray<T>>() {
              @Override
              public PSArray<T> getUpdatedOrNull(PSArray<T> current) {
                  MutableArray<T> next = MutableArrayFromIterable.create(current);
                  boolean success = NextPermutation.step(next, comparator);
                  return success ? next : null;
              }
          });
      }
docs: SRM464-1-250 is a good problem to solve using this.