I have been tasked with the following prompt for a coding project:

Write a C program in Linux that will read two input files, identify frequent common words that appear
in both files if their number of occurrences are higher than or equal to the specified frequency limit for
both files, and write them into an output file in decreasing sorted order based on their total frequency
value.
For each input file, your program will build a separate input linked list in ascending sorted order
based on the word field, where strcmp() is used for comparison while building these input lists.
Each node of the lists will contain a unique word that exists in that file and the number of occurrence
of that word within that file. Hence, each node of the list will be a
struct having fields to store the word itself (char *) and its count (int). You will build the lists
as doubly linked lists, where nodes have both next and previous pointers.
After building these two input lists, your program will find the common words in both lists if their
count is larger than or equal to the specified frequency limit in both files, calculate their total count
considering both files, and build a third output linked list that will be used for printing the result into
an output file in decreasing sorted order based on the total count value. You must implement and
use the insertion sort algorithm to sort the output list. If multiple words have the same count, then
tie-breaking will be done based on the word field in ascending order, again using the strcmp()
function.

I have been able to successfully read two separate .txt files and count the words that appear in each as well as incrementing for words that occur multiple times. However, I cannot seem to sort the counts from each file in decreasing order so that when I compare the two lists and choose a frequency number that it would then only display words that have appeared at least a certain number of times.