I'm interested in an efficient way to store pairs of numbers and sort them by the value of one of the numbers. Let's say I have a list of numbers:
(1, 2), (3, 5), (4, 3), (7, 8)
These pairs must be somehow stored and then sorted in descending order of the second number, so the order of these pairs is
(7, 8), (3, 5), (4, 3), (1, 2)
What will be the Java code for this? I know C ++ std::pair, but I was interested to know about the procedure in Java.
source
share