Skip to content

Instantly share code, notes, and snippets.

@twof
Created January 8, 2016 02:09
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 twof/88578aab8861d6c24340 to your computer and use it in GitHub Desktop.
Save twof/88578aab8861d6c24340 to your computer and use it in GitHub Desktop.
while(sorted != true){
for (int i=0; i<SIZE-1; i++){
if (SortableArray[i]>SortableArray[i+1]) {
temp = SortableArray[i];
SortableArray[i] = SortableArray[i+1];
SortableArray[i+1]=temp;
}else{
counter++; //every time a set is in order, add one to counter
}
}
if (counter == SIZE-1) { //if everything is in order, sorted is true
sorted=true;
}else{
counter=0; //otherwise, return it to 0
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment