Create a gist now

Instantly share code, notes, and snippets.

package sort;
public class InsertionSort implements Sort {
public int[] sort(int[] numbers) {
int size = numbers.length;
for (int i = 1; i < size; i++) {
for (int j = 0; j < i; j++) {
if (numbers[j] > numbers[i]) {
int tmp = numbers[j];
numbers[j] = numbers[i];
numbers[i] = tmp;
}
}
}
return numbers;
}
}
@nyoronzoi
Owner

挿入ソート

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment