add sort (ascending) method

This commit is contained in:
2017-02-05 14:18:47 +01:00
parent a535761b46
commit f7870a15a7
2 changed files with 19 additions and 0 deletions

View File

@@ -386,6 +386,17 @@ public class IntListTest {
Assert.assertNotEquals(a.hashCode(), b.hashCode());
}
@Test
public void testSort() {
final IntList list = new IntList();
list.addAll(4, 2, 3, 1);
list.sort();
final int[] expectedE = new int[] { 1, 2, 3, 4 };
Assert.assertArrayEquals(expectedE, list.toArray());
}
private int[] removeElements(final int[] data, final int... removedElements) {
final int[] result = new int[data.length - removedElements.length];
final List<Integer> blacklist = Arrays.stream(removedElements).boxed().collect(Collectors.toList());