Sorting algorithms/Bubble sort: Difference between revisions

Content added Content deleted
(Fixed Java Code)
m (→‎{{header|Java}}: Fixed it again)
Line 843:
=={{header|Java}}==
Bubble sorting (ascending) an array of any <tt>Comparable</tt> type:
<lang java>doboolean {changed = false;
do {
boolean changed = false;
for (int a = 0; a < comparable.length - 1; a++) {
for (int ifa = 0; (comparable[a].compareTo( < comparable[a.length +- 1]); > 0a++) {
if int tmp = (comparable[a];.compareTo(comparable[a + 1]) > 0) {
comparable[a] E tmp = comparable[a + 1];
comparable[a] = comparable[a + 1] = tmp;
changed comparable[a + 1] = truetmp;
} changed = true;
}
}
} while (changed);</lang>