Skip to content
Advertisement

Tag: sorting

Sort 2d String array by integer in first column

I have a 2d array in Java 8: String data[][] = new String[i][2]; And it looks like this: Player1 8 Player5 3 Player3 9 Player4 5 … and I want to sort it to have the highest score at the top: Player3 9 Player1 8 Player4 5 Player5 3 How can I sort this or is there a better way

Java Quick Sort Performance

I was doing sorting array problems and found one of the quick sorting solution extremely fast, and the only difference is the two lines of code in function 1Partition. Wondering why the following two lines of code in 1Partition can greatly improve the performance: Here’s the full source code: } Answer I guess you are doing the question on a

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. 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],

Advertisement