Skip to content

Instantly share code, notes, and snippets.

@vyruz
Last active December 12, 2015 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vyruz/4729192 to your computer and use it in GitHub Desktop.
Save vyruz/4729192 to your computer and use it in GitHub Desktop.
void bubblesort(vector<int> &data) {
bool swap = true;
int temp;
int size = data.size();
while(swap == true){
for(int i=0; i < size; i++){
if(data[i] < data[i-1]){
temp = data[i];
data[i] = data[i+1];
data[i+1] = temp;
swap = true;
}
}
if(swap == false){
return;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment