Jump to content

Sorting algorithms/Bubble sort: Difference between revisions

Fixed Java Code
(→‎{{header|Eiffel}}: Removed "beta" from version 6.6)
(Fixed Java Code)
Line 845:
<lang java>do {
boolean changed = false;
for (int a = 0; a < comparable.length - 21; a++) {
if (comparable[a].compareTo(comparable[a + 1]) > 0) {
int tmp = comparable[a];
Line 853:
}
}
} while (!changed);</lang>
 
For descending, simply switch the direction of comparison:
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.