Skip to content

Instantly share code, notes, and snippets.

@simplexityx
Created January 30, 2017 12:04
Show Gist options
  • Save simplexityx/52a4c8b1941812ca6560aec0e2831750 to your computer and use it in GitHub Desktop.
Save simplexityx/52a4c8b1941812ca6560aec0e2831750 to your computer and use it in GitHub Desktop.
set_t *sort(set_t *set){
if(set->head==NULL){
return set;
}
if(set->head->next==NULL){
return set;
}
node_t *tmp = set->head;
node_t *tmp2 = set->head->next;
while(tmp2!=NULL){
while(tmp2!=tmp){
if(tmp->elem>tmp2->elem){
swap(tmp,tmp2);
}
tmp=tmp->next;
}
tmp=set->head;
tmp2=tmp2->next;
}
return set;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment