Implemented merge sort for sorting lists