Код: Выделить всё
public void bubbleSort()
{
int out, in;
for(out=nElems-1; out>1; out--) // outer loop (backward)
for(in=0; in a[in+1] ) // out of order?
swap(in, in+1); // swap them
}
Код: Выделить всё
private void swap(int one, int two)
{
long temp = a[one];
a[one] = a[two];
a[two] = temp;
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... ert-lafore
Мобильная версия