Javascript - Trying to Group the Output
Hi all,
I have done a jQuery post to get a record set of popular products in varied categories
- then I am doing an .each loop to display the products.
But what I want is to somehow be able to group them by the category field so the display will look something like:
category 1
-- Product 1 (category 1 not shown)
-- Product 4 (category 1 not shown)
-- Product 27 (category 1 not shown)
category 2
-- Product 8 (category 2 not shown)
-- Product 2 (category 2 not shown)
-- Product 6 (category 2 not shown)
etc.
So I am not sure how to get this going in javascript.
Is there a way to create an array from what I have already to get a DISTINCT list of unique categories?
my simple idea is to do 2 loops:
loop 1 through the unique distinct categories
then within each - loop a second time to just display items that match THIS CATEGORY.
just a thought - any help would be appreciated.
