Skip to content
Advertisement

Sort List of Values in a Map in descending order

I have a Map with List of Doubles.

unsorted map contents: {A=[0.02, 0.03], B=[0.0, 0.01], C=[0.01, 0.0], D=[0.05, 1.03], E=[1.01, 0.03]}

I need to sort in descending order for List(0). I have tried the below logic but its sorting in ascending order.

JavaScript

Actual output: {B=[0.0, 0.01], C=[0.01, 0.0], A=[0.02, 0.03], D=[0.05, 1.03], E=[1.01, 0.03]}

Expected output: {E=[1.01, 0.03], D=[0.05, 1.03], A=[0.02, 0.03], C=[0.01, 0.0], B=[0.0, 0.1]}

Please help me with logic on Java8 streams.

Advertisement

Answer

Try this:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement