Java implementation for merge sort