merge sort non recursive and template