Implementation of merge sort algorithm