problem implementing- printing sorted linked list
In my program i have a linked list which i want to print all of her elements.
i want to print the elements in a specific order therefore i need first to sort the linked list.
The problem is that i need to sort it according to 3 parameters- I mean after i finish one paramter i move to the next parameter and that`s exactly my problem i don`t know how to
sort according to the second parameter without ruining the sort according to the first parameter.
Thanks for the help,
Re: problem implementing- printing sorted linked list
In your comparison routine you will need to code how it determines which element comes first.
So if you sort, say, people first by age then by height, this means you first compare two people's ages, then if those are equal you compare the heights. Let's say you're writing a function to determine if person1 > person2:
2: If person1.age < person2.age then we return FALSE immediately
3: If person1.age == person2.age then we need to look at the height
3a: person1.height > person2.height so we return TRUE
3b: person1.height <= person2.height so we return FALSE.
|All times are GMT +5.5. The time now is 13:57.|