Anonymous user
Sorting algorithms/Bubble sort: Difference between revisions
→{{header|Java}}
m (→{{header|Java}}: Fixed it again) |
|||
Line 843:
=={{header|Java}}==
Bubble sorting (ascending) an array of any <tt>Comparable</tt> type:
<lang java>public static <E extends Comparable<? super E>> void bubbleSort(E[] comparable) {
changed = false;
comparable[a] = comparable[a + 1]
changed = true;
}
}
} while (changed);
}
For descending, simply switch the direction of comparison:
|