I have two arrays:
String [] ids= new String [5];
String [] points= new String [5];
String one="a,b,c,d,e";
//or
String one="nepal,japan,finland ,brazil,spain";
String two="100,500,200,400,300";
ids= one.split(",");
points= two.split(",");
Now i want to sort points in descending order just like.
500,400,300,200,100 with respective ids b,d,e,c,a
how can i do that.
But i try this point descending order which is ok, but how to ordered ids with respective id.
Arrays.sort(points, Collections.reverseOrder());
Arrays.toString(points);
or
Arrays.sort(points);
if i do same as ids which is also descending. but which is not output.
Edited:
if i have replace
a,b,c,d,e letter to contries name or time.
String one="a,b,c,d,e";
// or
String countries = "nepal,japan,finland,brazil,spain";
// or
String time="0:10,1:25,4:00,2:10,0:55";
You can define your own
Comparator, something like this:and here is the main:
OUTPUT:
EDIT:
As a general class, here is the same class with generic implementation:
The main:
OUTPUT: