# Merge Sort

```cpp
template<size_t size>
void merge_sort_rec(array<int, size> &ar, int first, int last) {
    if (last - first > 1) {
        int middle = first + (last - first) / 2;
        merge_sort_rec(ar, first, middle);
        merge_sort_rec(ar, middle, last);
        inplace_merge(ar.begin() + first, ar.begin() + middle, ar.begin() + last);
    }
}

template<size_t size>
void merge_sort(array<int, size> &ar) {
    merge_sort_rec(ar, 0, ar.size());
}
```
