Skip to content

Instantly share code, notes, and snippets.

@tsabunkar
Created January 25, 2019 06:12
Show Gist options
  • Save tsabunkar/f1e1aa6f27a9b95012885c6f420551d7 to your computer and use it in GitHub Desktop.
Save tsabunkar/f1e1aa6f27a9b95012885c6f420551d7 to your computer and use it in GitHub Desktop.
int[] Array = {30, 20, 10, 40, 60, 50};
for(int k = 0; k < Array.length; k++) {
int holder = Array[k];
int j = k;
while(j > 0 && holder < Array[j - 1]) {
Array[j] = Array[j-1];
j = j - 1;
Array[j] = holder;
}
}
for(int n = 0; n < Array.length; n++)
System.out.print(Array[n] + " ");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment