public class Solution {
public static void main(String[] args) {
Solution solution = new Solution();
int[] arr = {5, 2, 3, 4, 1};
solution.insertSort(arr);
}
private void insertSort(int[] arr) {
int n = arr.length;
int i, j, t;
for (i = 1; i < n; i++) {
t = arr[i];
for (j = i - 1; j >= 0 && arr[j] > t; j--) {
arr[j + 1] = arr[j];
}
arr[j + 1] = t;
}
}
}