3-way Mere Sort Algorithm

A comparison-based sorting algorithm that sorts an array by dividing the array into three parts and merging the two sorted parts back into a single sorted array. This is typically used for sorting arrays with many duplicate elements.