public class InsertSort {
public static void main(String[] args) throws NumberWrongException {
int[] numbers = ArrayTools.getRandomInts(7, -9, 9);
ArrayTools.printInts(numbers);
ArrayTools.printInts(insertSort(numbers));
}
public static int[] insertSort(int[] numbers) {
int temp;
int j = 0;
for (int i = 0; i < numbers.length; i++) {
temp = numbers[i];
for (j = i; j > 0 && temp < numbers[j - 1]; j--) {
numbers[j] = numbers[j - 1];
}
numbers[j] = temp;
}
return numbers;
}
}