DEV Community

dgloriaweb
dgloriaweb

Posted on

How to build a proper array of basket data, sorting by category and merging items into one?

Hi, I have a basket that isn't too sophisticated, basically it is not in any kind of order, meaning memberships can follow coke, that's followed by tickets, one fanta, one more fanta, etc. Basically in the order as the items were added to the basket. Do you have a good way to sort items first by category then group similar items, like 2 fantas, etc, or it only can be done with multiple array manipulation techniques? I feel like some recursive arrays should also be used here, merging 3 or more items together? Thank you for your thoughts.

Top comments (0)