Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool sortByValue(struct filmList** start, int option) {
- if (*start == NULL) return false;
- int match = 0, counter = 0;
- struct filmList* current = (*start)->next;
- struct filmList* previous = *start;
- int number = 0;
- char* string = NULL;
- int sizeOfList = getSizeOfList(current);
- for (int i = 0; i < sizeOfList - 1; i++) {
- if (isBigger(current, previous, option)) {
- swapElements(¤t, &previous);
- }
- current = current->next;
- previous = previous->next;
- }
- return true;
- }
- bool sortByPointers(struct filmList** start, int option) {
- if (*start == NULL) return false;
- int match = 0, counter = 0;
- struct filmList* current = (*start)->next;
- struct filmList* previous = *start;
- struct filmList* tempCurrent;
- struct filmList* tempPrevious;
- int number = 0;
- char* string = NULL;
- int sizeOfList = getSizeOfList(current);
- for (int i = 0; i < sizeOfList - 1; i++) {
- for (int j = 0; j < sizeOfList - i - 1; j++) {
- if (j == 0) {
- tempCurrent = current;
- tempPrevious = previous;
- }
- if (isBigger(tempCurrent, tempPrevious, option)) {
- swapPointers(¤t, &previous, start);
- struct filmList* temp;
- temp = tempCurrent;
- tempCurrent = tempPrevious;
- tempPrevious = temp;
- }
- tempCurrent = tempCurrent->next;
- tempPrevious = tempPrevious->next;
- }
- current = current->next;
- previous = previous->next;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement