Web Hosting Talk







View Full Version : JAVA HELP PLEASE Linked lists


davidb
08-06-2003, 06:41 PM
Alright, I am so close of finishing this. I am trying to sort a linked list, by two fields, date and time, first by date, then by time for each seperate date. I can do it for date, but both at once just screws up, by that I mean it changes around the dates when trying to change the times. This is the code that works, just for the date:

NodeShow $Prev = $Head;
NodeShow $Temp = $Head;

while ((($Temp != null) && $Temp.$Info.getDate()<=$Info.getDate()) )
{

$Prev = $Temp;
$Temp = $Temp.$Next;
}
if ($Temp == $Head)
{
$Temp = new NodeShow();
$Temp.$Info = $Info;
$Temp.$Next = $Head;
$Head = $Temp;
}
else
{
$Temp = new NodeShow();
$Temp.$Info = $Info;
$Temp.$Next = $Prev.$Next;
$Prev.$Next = $Temp;
}





Then in the while satement I try to add

($Temp.$Info.getTimes()<=$Info.getTimes())

I see why it screws this up, but I just cant find a solution, and right now I am BRAIN FRIED from this program. Any suggestions to get it to sort dates then times?