Hello, I have a linked list with the following data in it reflecting a title (name), int (# copies) and float (price).
I'm supposed to sort this linked list by prices (highest to low) and then print the titles. From what I've seen, the best method is using selection sort, but I'm having issues implementing the linked list.

Header file

#ifndef BOOKSTORE_H
#define BOOKSTORE_H
#include <string>
using namespace std;

class BookStore
{
private:
   
   struct ListNode
   {
	   string title;
       int copies;
	   float prices;
	   struct ListNode *next;  
   }; 

   ListNode *head;            

public:
  
   BookStore();
   ~BookStore();
   
   void appendNode(string, int, float);
   void findTitle();
   void reorderTitle();
   void deleteNode();
   void sortList(); 
   void displayList();
    
};
#endif

Recommended Answers

All 2 Replies

What problems specifically? Why not just start with a simple bubble sort?

i think insertion sort will be faster and easier

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.