We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent db4f873 commit 338fcedCopy full SHA for 338fced
Sorts/ShellSort.java
@@ -22,10 +22,11 @@ public <T extends Comparable<T>> T[] sort(T[] array) {
22
for (; gap > 0; gap /= 3) {
23
for (int i = gap; i < length; i++) {
24
int j;
25
- for (j = i; j >= gap && less(array[j], array[j - gap]); j -= gap) {
+ T temp = array[i];
26
+ for (j = i; j >= gap && less(temp, array[j - gap]); j -= gap) {
27
array[j] = array[j - gap];
28
}
- array[j] = array[i];
29
+ array[j] = temp;
30
31
32
return array;
0 commit comments