merge sort with insertion sort and binary search optimization