Skip to content

Instantly share code, notes, and snippets.

@cristianmiranda
Created September 20, 2015 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cristianmiranda/93cc0d5e93183fccd7f1 to your computer and use it in GitHub Desktop.
Save cristianmiranda/93cc0d5e93183fccd7f1 to your computer and use it in GitHub Desktop.
Burbuja.java
package edu.unlam.impl;
import edu.unlam.Ordenadora;
public class Burbuja extends Ordenadora {
@Override
public void sort(Comparable[] elements) {
int n = elements.length;
for (int i = 0; i < (n - 1); i++) {
for (int j = 0; j < n - i - 1; j++) {
if (elements[j].compareTo(elements[j + 1]) > 0) {
Comparable swap = elements[j];
elements[j] = elements[j + 1];
elements[j + 1] = swap;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment