Skip to content

Instantly share code, notes, and snippets.

@mochow13
Created September 15, 2018 07:50
Show Gist options
  • Save mochow13/7f4b9f1786d728c4bd5b38bf62251fce to your computer and use it in GitHub Desktop.
Save mochow13/7f4b9f1786d728c4bd5b38bf62251fce to your computer and use it in GitHub Desktop.
void merge_sort(auto l, auto r)
{
if(r-l>1)
{
auto mid=l+(r-l)/2;
merge_sort(l,mid);
merge_sort(mid,r);
std::inplace_merge(l,mid,r);
}
}
std::vector<int> collection = {2,4,4,1,1,3,9};
merge_sort(begin(collection), end(collection));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment