Почему не проходить?
package com.javarush.task.task19.task1919;
/*
Считаем зарплаты
*/
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataOutput;
import java.io.FileReader;
import java.util.*;
public class Solution {
public static void main(String[] args) throws Exception{
String nameFile = args[0];
// String nameFile = "C:\\one.txt";
BufferedReader reader = new BufferedReader(new FileReader(nameFile));
Map<String, Double> hashMap= new HashMap<>();
while (reader.ready()){
String stringLane = reader.readLine();
String [] nameDouble = stringLane.split(" ");
String name = nameDouble[0];
Double vd = Double.parseDouble(nameDouble[1]);
if(hashMap.containsKey(name)){
hashMap.put(name, hashMap.get(name) + vd);
} else {
hashMap.put(name, vd);
}
}
reader.close();
// List list = new LinkedList<>(hashMap.entrySet());
/*Collections.sort(list, new Comparator<Map.Entry<String, Double>>() {
@Override
public int compare(Map.Entry<String, Double> a, Map.Entry<String, Double> b) {
// return (int) (a.getValue() - b.getValue());
return (a.getValue()).compareTo(b.getValue());
}
});*/
/*for (Map.Entry<String, Double> map : hashMap.entrySet()){
String name = map.getKey();
Double d = map.getValue();
System.out.println(name + " " + d);
}*/
ArrayList<Double> list1 = new ArrayList<>();
//ArrayList<Double> list1 = (ArrayList<Double>) set;
for (Map.Entry<String, Double> a : hashMap.entrySet()){
list1.add(a.getValue());
}
Collections.sort(list1);
//Collections.s
ArrayList<String> names = new ArrayList<>();
for(Double l : list1){
for(Map.Entry<String, Double> a : hashMap.entrySet()){
String name = a.getKey();
Double z = a.getValue();
if(l.equals(z)){
names.add(name);
}
}
}
for(int i = 0; i < names.size(); i++) {
System.out.println(names.get(i) + " " + list1.get(i));
}
}
}