Merge Sort basically takes the old adage "divide and conquer" and applies that to arrays.

This is how it works.

  1. It takes an array and splits it down the middle.
  2. It can break it down into even smaller arrays until there's just one instance
  3. Then it sorts that instance.
  4. Then it combines that small array with other other small arrays and then sorts those until all of the arrays are combined

The complexity of this algorithm is O(n log(n)), which means that it's very, very efficient.

You can find out more about this here.

Sources: https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-implement-merge-sort/301614

https://flaviocopes.com/merge-sort-javascript/