Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

I have a TreeMap<Product, Integer>. I conduct orders by price using a comparator. shop.addProduct(new Phone("Samsung",799),shop.countProduct); shop.addProduct(new Food("Milk",4),s

I have a TreeMap<Product, Integer>.I conduct orders by price using a comparator.

        shop.addProduct(new Phone("Samsung",799),shop.countProduct);        shop.addProduct(new Food("Milk",4),shop.countProduct);        shop.addProduct(new Food("Bread",2),shop.countProduct);        shop.addProduct(new Toy("Lego",130),shop.countProduct);

this will be the result

{Bread_2_=2, Milk_4_=1, Lego_130_=3, Samsung_799_=0}

Question: I can't figure out how to make countProduct count in ascending order

Expected Result{Bread_2_=0, Milk_4_=1, Lego_130_=2, Samsung_799_=3}

Tried to create a comparator by quantity

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question