'How to create a sequence by using LinkedList and Hashmap in the class "add" that all the prices of the products are in ascending order?

My idea was to create a "For" loop right after the "if" statement where "basket != null", in that way trying to add that prices are in ascending order, but have been trying for some time and still no results. I had to create class names string in t and double as private ones, so there is no misunderstanding.

public static void add (Hash Map<String, Linked List> order) { Linked List basket;

    System. out. print("clients ID: ");
    String id = sc. next();
    Product p = Product. input Product(s c);
    basket = order. get(id);
    if (basket != null) {
        basket. add(p);
    } else {
        basket = new Linked List<Product>();
        basket. add(p);
        order. put(id, basket);
    



    

 


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source