c++ vector bubble sort

You need to pass by reference; by making a copy, you sort a temporary copy, and then that’s it; it disappears and the original is still unsorted, because, once again, you sorted only a temporary copy of the entire vector. So change vector<int> a to vector<int>& a. Here’s the code, fixed: http://coliru.stacked-crooked.com/a/2f118555f585ccd5