# Thread: strategy of sorting in this problem..

1. ## strategy of sorting in this problem..

Code:
```here is the original question:
in order to relocate a factory there where hired 10 trucks.
in order to make it safely  the cost of insurance in relation with the items in the trucks
were calculated.
every item  belongs to one of three categories 0 ,1 ,2
for  category 0 there is 0.02% of the item value  payment .
for category 1 there is 0.07% of the item value  payment  .
for  category there is 0.15% of the item value  payment.

for every truck there is a file in which every line is an item which looks like this:
ID{5 chars}  how_many{4 chars} comment{25 chars}
the file is sorted by ID in ascending order.

also there is a catalog file in which each line also represents an item.
ID{5 chars}  category{1 char 0,1,2}  price{6 chars}

the file is sorted by ID in ascending order.

before the ride the manager asked to create a file for each category
in which there would be the items which were transported from this category.
each   line in this file  represents an item
ID{5 chars} amount{5 chars} price{6 chars} insurance_cost{XXXXX.XX 5 chars whith 2 chars precition.  }

write a function called

void insure (FILE* f_van[10],FILE *f_item, char* fname[3])

f_van is the truck files
f_item is the catalog file
fname[3] is the names of files which the manager asked to make

the file needs to be sorted by ID in ascending order.
"```
this is so complex i dont know what is the strategy here

??

2. The strategy for sorting here is "ascending by ID number". Fortunately or unfortunately for you, that is completely irrelevant, since the data will be given to you in ascending order by ID number, so you won't have to sort it.

3. ok,
what two files do i compare by id?
where do i put the match?
in what step i do the calculation?

can you tell me the general strategy?

4. Again this is a classic example of how would you do this without writing any code. The way I see it:

1. You have 10 vans each with their own shipping docket of items by ID only and how many of each they are shipping.

2. You will need to compare your catalog of items against each van shipment. You have the items IDs already on hand to accomplish this and now you have their catalog and pricing.

3. From step 2 you will then need to compare the shipments of each van to that of what your manager wants you to do in order to list each item by catagory and by ascending order of item IDs. As tabstop mentioned that is pretty much done for you.

5. ok this ill try to write it down into code.
thanks