Mergesort is a sorting algorithm that works by recursively dividing an array into two halves, sorting each half, and then merging the two sorted halves into a new sorted array. This process takes O(n log n) time, making it more efficient than other O(n^2) sorting algorithms for large arrays. Mergesort is a stable sorting algorithm because when merging two sorted halves, it always chooses equal elements from the left subarray first, keeping them in their original relative order.