0

How to make "pair" of more than 2 elements then sort by first element in java?

Paring in java

15th Mar 2020, 7:53 PM
R_N
6 Answers
+ 1
Hello R_C Can you add an example? If you have only a pair and if you are using numbers you can use < and >. for example 4, 3 4 > 3 -> swap them to get 3, 4
15th Mar 2020, 8:14 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
Can you please make your question more descriptive? Also, try to include a program of your own, as currently this seems like homework.
15th Mar 2020, 8:14 PM
Jianmin Chen
Jianmin Chen - avatar
+ 1
Hello R_C My idea is to store the name and the index in a hashmap. a has index 0, 4 belongs to a and has index 0 and 25000 belongs to a and has index 0. a = 0 c = 1 g = 2 After storing the index you can do what ever you want with the names. And you don't need to do anything with the other arrays. Here is a small code example: https://code.sololearn.com/cUnqcl3V7DoQ/?ref=app
16th Mar 2020, 9:13 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
@Denise Roßberg Got it. Thank you
17th Mar 2020, 4:27 AM
R_N
+ 1
Denise Roßberg What if two or more names are same
17th Mar 2020, 8:01 AM
R_N
0
Denise Roßberg if there are three arrays Name={"a", "c", "g"} ID={4,1,9} Salary={25000,42000,11000} i.e; a person name "a" having ID 4 and salary 25000 I want to sort the combined array i ascending according to ID. i.e; Name ={"c", "a", "g"} ID = {1,4,9} Salary = {42000,25000,11000} and show the answer as c 1 42000 a 4 25000 g 9 11000
16th Mar 2020, 8:42 PM
R_N