Solution for Insertion and merge sort