Skip to content

Instantly share code, notes, and snippets.

@yndx-handbook
Created September 1, 2022 16:11
Show Gist options
  • Save yndx-handbook/7ff18234ed9cd73e4d0ef71ec4c1aa5c to your computer and use it in GitHub Desktop.
Save yndx-handbook/7ff18234ed9cd73e4d0ef71ec4c1aa5c to your computer and use it in GitHub Desktop.
void BubbleSort(vector<int>& values) {
for (size_t idx_i = 0; idx_i + 1 < values.size(); ++idx_i) {
for (size_t idx_j = 0; idx_j + 1 < values.size() - idx_i; ++idx_j) {
if (values[idx_j + 1] < values[idx_j]) {
swap(values[idx_j], values[idx_j + 1]);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment