I know bubble sort is probably not the fastest way to do this but its acceptable. i'm just having trouble with adjusting the algorithm to double link lists from arrays.
My double linked lists have a type int and a type string to hold a number and a word. My list was sorted with an insertion sort that I wrote to sort alphabetically, now I need to reorder my double linked list numerically, greatest to least.
My trouble spot is how to run this loop so that it is properly sorted thoroughly and not just one time.
here's what i've managed to get down so far:
void DblLinkedList::ReorderListNumeric()
{
dummy = new Node();
temphead = head;
temp = head->next;
while(tempTwo->next != NULL)
{
if(temp->wordCount < tempTwo->wordCount)
{
dummy->word = tempTwo->word;
dummy->wordCount = tempTwo->wordCount;
tempTwo->word = temp->word;
tempTwo->wordCount = temp->wordCount;
temp->word = dummy->word;
temp->wordCount = dummy->wordCount;
}
temp = tempTwo;
tempTwo = tempTwo->next;
}
}