Skip to content

Trying to sort a Double Collection

I am trying to sort a Collection. I cant seem to get my code to work with what I have found online.


[104.131119, 104.188937, 93.174548, 100.533096, 97.902247, 98.608619, 93.380054, 106.690206, 106.461181, 108.190245]


Collection<Double> csvData = new ArrayList<Double>();

//logic of reading csv file and adding data to collection

//Adding into the collection using 

Collections.sort(csvData); // error, The method sort(List<T>) in the type Collections is not applicable for the arguments (Collection<Double>

Any help would be appreciated.


You must declare the variable like this:

List<Double> csvData = new ArrayList<Double>();

The error is clear: the Collections.sort() method expects a List object, a Collection won’t work.