ProbabilitySelector implements Selector<G, C> { static double[] sortAndRevert(final double[] array) { final int[] indexes = ProxySorter.sort(array); final double[] result = new double[array.length]; for (int i = 0; i < result.length; ++i) { result[indexes[i]] = array[indexes[result.length - 1 - i]]; } return result; } protected  ProbabilitySelector(final boolean sorted); protected  ProbabilitySelector(); @Override ISeq<Phenotype<G, C>> select(
		final Seq<Phenotype<G, C>> population,
		final int count,
		final Optimize opt
	);  }
@Test(dataProvider = "arraySize") public void revert(final Integer size) { final double[] probabilities = array(size, new Random()); final double[] reverted = ProbabilitySelector.sortAndRevert(probabilities); for (int i = 0; i < size; ++i) { Assert.assertEquals( probabilities[i] + reverted[i], size - 1.0 ); } }
@Test(dataProvider = "arraySize") public void revertSortedArray(final Integer size) { final double[] values = array(size, new Random()); Arrays.sort(values); final double[] reverted = ProbabilitySelector.sortAndRevert(values); for (int i = 0; i < values.length; ++i) { Assert.assertEquals(reverted[i], (values.length - i - 1)); } }