the compareID function is a trifle odd. Typically the ?: operator is as follows
Code:
condition ? value if true : value if false
Thus the condition will always be true
It's not possible to give a reasonable answer to your question without knowing how you want the lists to be stored. Should they be sorted after the merge? Are the already sorted before?
If they are sorted before and you want them to be sorted after then look up the details of merge sort (google can help).