Merge sort has a runtime of O(n log n). It works by recursively dividing an array into halves and then merging the sorted halves. First it divides the array into single elements, sorts those, then merges them back together piece by piece into a fully sorted array.