Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1.  
  2. bool sortByValue(struct filmList** start, int option) {
  3. if (*start == NULL) return false;
  4. int match = 0, counter = 0;
  5. struct filmList* current = (*start)->next;
  6. struct filmList* previous = *start;
  7. int number = 0;
  8. char* string = NULL;
  9. int sizeOfList = getSizeOfList(current);
  10. for (int i = 0; i < sizeOfList - 1; i++) {
  11. if (isBigger(current, previous, option)) {
  12. swapElements(&current, &previous);
  13. }
  14. current = current->next;
  15. previous = previous->next;
  16. }
  17. return true;
  18. }
  19.  
  20. bool sortByPointers(struct filmList** start, int option) {
  21. if (*start == NULL) return false;
  22. int match = 0, counter = 0;
  23. struct filmList* current = (*start)->next;
  24. struct filmList* previous = *start;
  25. struct filmList* tempCurrent;
  26. struct filmList* tempPrevious;
  27. int number = 0;
  28. char* string = NULL;
  29. int sizeOfList = getSizeOfList(current);
  30. for (int i = 0; i < sizeOfList - 1; i++) {
  31. for (int j = 0; j < sizeOfList - i - 1; j++) {
  32. if (j == 0) {
  33. tempCurrent = current;
  34. tempPrevious = previous;
  35. }
  36. if (isBigger(tempCurrent, tempPrevious, option)) {
  37. swapPointers(&current, &previous, start);
  38. struct filmList* temp;
  39. temp = tempCurrent;
  40. tempCurrent = tempPrevious;
  41. tempPrevious = temp;
  42. }
  43. tempCurrent = tempCurrent->next;
  44. tempPrevious = tempPrevious->next;
  45. }
  46. current = current->next;
  47. previous = previous->next;
  48. }
  49. return true;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement