I'm trying to sort the products in production order report table by product category.
This is the original code: 
I tried to modify filter on foreach like this 
but when I do it no products are displayed in table. Does anyone know how can this filtering be applied? Thank you.