Working merge and insertion sort