Skip to content

Instantly share code, notes, and snippets.

@nyoronzoi
Created February 20, 2017 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nyoronzoi/a5d9ff951cb1133ab2e6ad7b4663984c to your computer and use it in GitHub Desktop.
Save nyoronzoi/a5d9ff951cb1133ab2e6ad7b4663984c to your computer and use it in GitHub Desktop.
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
Copy link
Author

挿入ソート

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