I'm not sure i follow your question.
Sorting is done on all of the values of a column, not just one. to sort on the category ID column you would just need to add:
ORDER BY CategoryId DESC to the recordset, you dont need to know a specific category ID value for sorting the recordset.
if you want to determine a specific category id, click on the category link in the Products menu and note the ProductCategoryID value in the querystring of the address browsers address bar, for example: