Here is merge sort in java with different scenarios