Question: I just need help with this method, thank you in advance ! // Q2 : sort (10 points) // This function is used to sort

 I just need help with this method, thank you in advance

! // Q2 : sort (10 points) // This function is used

I just need help with this method, thank you in advance !

// Q2 : sort (10 points) // This function is used to sort the list(array of structs) numerically by book ID. // Parse the list and compare the book IDs to check which one should appear before the other in the list. // Sorting should happen within the list. That is, you should not create a new array of structs having sorted books. [// Hint: Use a temp struct (already declared) if you need to swap two structs in your logic // the number of books currently stored in the list (initialized to 0) int count = 0; unsigned int bookId; void sort() { struct libraryRecord libraryTemp; // Enter code here // needed for swapping structs. Not absolutely necessary to use. // display message for user to check the result of sorting. printf(" Book list sorted! Use display option 'd' to view sorted list. "); Enter your selection: a: add a new book d: display book list r: remove a book from list s: sort book list by ID q: quit S Book list sorted! Use display option 'd' to view sorted list. Enter your selection: a: add a new book d: display book list r: remove a book from list s: sort book list by ID q: quit d Book Title: Sapiens Author Name: Yuval Book Type: Nonfiction Book ID: 1 Aisle number: 1 Book Title: The Alchemist Author Name: Paulo Book Type: Fiction Book ID: 2 Aisle number: 2 Book Title: A Promised Land Author Name: Barack Obama Book Type: Nonfiction Book ID: 3 Aisle number: 3 // Q2 : sort (10 points) // This function is used to sort the list(array of structs) numerically by book ID. // Parse the list and compare the book IDs to check which one should appear before the other in the list. // Sorting should happen within the list. That is, you should not create a new array of structs having sorted books. [// Hint: Use a temp struct (already declared) if you need to swap two structs in your logic // the number of books currently stored in the list (initialized to 0) int count = 0; unsigned int bookId; void sort() { struct libraryRecord libraryTemp; // Enter code here // needed for swapping structs. Not absolutely necessary to use. // display message for user to check the result of sorting. printf(" Book list sorted! Use display option 'd' to view sorted list. "); Enter your selection: a: add a new book d: display book list r: remove a book from list s: sort book list by ID q: quit S Book list sorted! Use display option 'd' to view sorted list. Enter your selection: a: add a new book d: display book list r: remove a book from list s: sort book list by ID q: quit d Book Title: Sapiens Author Name: Yuval Book Type: Nonfiction Book ID: 1 Aisle number: 1 Book Title: The Alchemist Author Name: Paulo Book Type: Fiction Book ID: 2 Aisle number: 2 Book Title: A Promised Land Author Name: Barack Obama Book Type: Nonfiction Book ID: 3 Aisle number: 3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!