templatizing linkedlist and implementing mergesort for arrays