implemented merge sort algorithm