Skip to content

Instantly share code, notes, and snippets.

@javierhonduco
Last active December 16, 2015 16:49
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 javierhonduco/27c7eceddffe1465aa5f to your computer and use it in GitHub Desktop.
Save javierhonduco/27c7eceddffe1465aa5f to your computer and use it in GitHub Desktop.
public void guardarFichaOrdenada(Ficha ficha){
/*
Se anade y luego ordena. Tiene ñacañá complejidad
que insertarlo si esta ordenado
*/
guardarFicha(ficha);
array = new Ficha[getSize()];
DNode<Ficha> current = getFirstNode();
for(int ii = 0; current != getTrailer(); current = current.getNextNode()){
array[ii] = getAt(ii);
++ii;
}
// Bubblesort modificado
Ficha aux = null;
for(int ii=0; ii < array.length; ++ii){
for (int jj = 1; jj < array.length-1; jj++) {
if(array[jj-1].getPropietario().getAppellidos().compareTo(array[jj].getPropietario().getAppellidos()) > 0){
aux = array[jj];
array[jj] = array[jj-1];
array[jj] = aux;
}
}
}
// Añadir a la lista
for(int ii=array.length; ii != 0; ++ii){
addLast(array[ii]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment