Bubble Sort dla Java Arraylist
public void bubbleSort(java.util.ArrayList aList) {
int n = aList.size();
int temp = 0;
for (int i = 0; i < n; i++) {
for (int j = 1; j < (n - i); j++) {
if (aList.get(j - 1) > aList.get(j)) {
//swap elements
temp = aList.get(j - 1);
aList.set(j-1, aList.get(j));
aList.set(j, temp);
}
}
}
}
Mohamad Rawf