I have a struct with different members and the ones I want to sort is int and string. The sorting will only affect one member of the struct and the hole linked list. As it is now I have one sorting function for every variable and I want one sorting function for all the variables. The difference in code are minimal but I can't seem to figure out how to only have one sorting function.

The only difference between the functions are the highlighted variable.

Ex function 1.

Code:void sortDiscID(sCdPost *CdRoot) { sCdPost *current; bool swap = true; current = CdRoot; if (current->pNext) current = current->pNext; while (swap || current->pNext != CdRoot) { swap = false; while (current->pNext != CdRoot) { if (current->discID > current->pNext->discID) { current->pPrev->pNext = current->pNext; current->pNext->pNext->pPrev = current; current->pNext->pPrev = current->pPrev; current->pPrev = current->pNext; current->pNext = current->pNext->pNext; current = current->pPrev; current->pNext = current->pNext->pPrev; swap = true; } current = current->pNext; } if (swap) current = CdRoot->pNext; } }//sortDiscID