0

I need help about array in java

You need to arrange the product by category using 2 dimensional array. Every row must have the same category. Can product: Corned Beef, Condensed Milk, Tuna, Evap Milk, Sprite, Beef Loaf, Coke Zero, Kremdensada, Pepsi The expected output: Row 1: Corned Beef, Tuna, Beef Loaf Row 2; Condensed Milk, Evap Milk, Kremdensada Row 3: Sprite,Coke Zero, Pepsi Can anyone help me I don't know how to sort a string array.

27th Jan 2021, 8:24 AM
Edward
1 Answer
+ 3
Question is unclear and missing detail. Assuming that they have a property "category" I would suggest first sorting them into a dictionary (key=category, value=list of products) and then creating 2d-array from that. Doesn't look like you have to sort anything, rather just bin/group by category
27th Jan 2021, 8:39 AM
Benjamin JĂŒrgens
Benjamin JĂŒrgens - avatar