This commit is contained in:
amontano 2003-04-05 00:03:44 +00:00
parent 341bea3c16
commit e7684dedcd

View file

@ -81,6 +81,23 @@ public class Link
return new Link(obj);
}
public Link sort()
{
Link newCabeza = (Link) clone(), next = next(), newLink;
while (next!=null)
{
newLink = (Link) next.clone();
if (newLink.toString().compareTo(newCabeza.toString())<=0)
{
newLink.siguiente = newCabeza;
newCabeza = newLink;
}
else newCabeza.insertSorted(newLink);
next = next.next();
}
return newCabeza;
}
public void insertSorted(Link link)
{
if (siguiente==null)
@ -94,20 +111,4 @@ public class Link
else siguiente.insertSorted(link);
}
public Link sort()
{
Link newCabeza = (Link) clone(), next = next(), newLink;
while (next!=null)
{
newLink = (Link) next.clone();
if (newLink.toString().compareTo(newCabeza.toString())<=0)
{
newLink.siguiente = newCabeza;
newCabeza = newLink;
}
else newCabeza.insertSorted(newLink);
next = next.next();
}
return newCabeza;
}
}