Weird table of contents
Hi there.
I'm creating a product index with the table of contents function for a catalogue. The catalogue has nearly 200 pages and around 1500 products in it.
The layout of the product pages is as per the screenshot below. Each of the product has its own text box. In each text box, it starts with the product name. Then a table contains the technical specifications. And finishes with few feature points. For some of the products, there are multiple product codes for different colours of the same product.

The colours in the screenshot represent different paragraph styles. Please refer to the next screenshot.

I like to have the product index appears like the order in the next screenshot. Which has the product code first then the product name. And the products should be listed in alphabetical order of the product codes (I have manually moved everything into correct order to take this screenshot). The follow screenshots are my settings in the table of contents window.



However, the result I've got is totally different to what I like it to be. Instead of product code, it starts with the product names. And in some of the entries, some product codes have gone into the previous or next product listings. And it grabs incorrect product names from a different products in some cases. That makes the index totally useless unless I manually move things around.

After some research, I learnt why the product names appears before product codes, which is opposite to what I wanted. I think that's because InDesign reads the line above the table first and put it into the list first. Seems like there is no workaround unless I redesign the layout. I guess the best solution is to spend few hours moving all the product names in the product index to underneath the product codes manually. I believe it will take much less time than redesign the layout and apply it to every single text box.
The main problem I really need to resolve is the order of the products. How can I put the products in an order fellow the alphabetical order of the product codes and have the correct product names go with the product codes?
I have uploaded a test file (both indd or idml formats) to the link below.
https://dl.dropboxusercontent.com/u/27633725/TOC-Test.indd
https://dl.dropboxusercontent.com/u/27633725/TOC-Test.idml
Thank you in advance for your help.
