Question: I'm writing a C++ code for my school that reads a data file that displays different name of different classes and the number of boxes

I'm writing a C++ code for my school that reads a data file that displays different name of different classes and the number of boxes of cookies that were sold by each class. I have read the file and also have correct output for the program but, I will get an extra point if I can sort the parallel array. I have an example of the output and I was able to sort the numerical values in ascending order but I can't get the name of the class to correspond to the values.

Example of my output.

class Name boxes of cookies sold

---------

cat 68

dog 55

cow 95

horse 105

(Note: There are more data than that is displayed here, in very random order).

so now i need to sort this in an order where class name corresponds the number of boxes sold.

Example of output I want is

horse 105

cow 95

cat 68

dog 55

Would you please help me sort this type of data? Thank you!!

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!