Skip to content

Instantly share code, notes, and snippets.

@h0hmj
Created March 19, 2018 08:02
Show Gist options
  • Save h0hmj/22841742f531a3eae4a1966cf7105577 to your computer and use it in GitHub Desktop.
Save h0hmj/22841742f531a3eae4a1966cf7105577 to your computer and use it in GitHub Desktop.
bubble sort
#include <utility>
#include <vector>
void bubble_sort(std::vector<int>& nums) {
for (int i = 0; i < nums.size(); i++) {
for (int j = nums.size() - 1; j > i; j--) {
if (nums[j] < nums[i]) {
std::swap(nums[i], nums[j]);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment