Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2020
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. void swapNodes(song *a, song *b)
  2. {
  3.     // swap di utils.h
  4.     swap(a->name, b->name);
  5.     swap(a->artist, b->artist);
  6.  
  7.     unsigned short int t = a->length;
  8.     a->length = b->length;
  9.     b->length = t;
  10. }
  11.  
  12. void selectionSort(Playlist l)
  13. {
  14.     song *start = l->head;
  15.     song *temp;
  16.     song *min;
  17.     while (start->next != NULL)
  18.     {
  19.         min = start;
  20.         temp = start->next;
  21.  
  22.         while (temp != NULL)
  23.         {
  24.             if (cmpItem(min->name, temp->name) > 0)
  25.                 min = temp;
  26.  
  27.             temp = temp->next;
  28.         }
  29.  
  30.         swapNodes(start, min);
  31.         start = start->next;
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement