An analytics dashboard displays products with their sales count and rating.
Users can sort products using:
- Top Selling — highest sales first
- Highest Rated — highest rating first
The current implementation has a bug: sorting appears to work sometimes, but switching between sorting modes produces incorrect results because the original product array is being mutated.
Fix the application so both sorting modes work correctly and repeatedly.