I have this LinkedHashMap containing Integer indexes and object Paire for values :
Map<Integer, Paire> population1 = new LinkedHashMap<>();
My Paire class is rather simple and looks like this :
public class Paire {
float valeur;
int index;
public Paire(LinkedList<Sommet> liste, float valeur, int index) {
this.liste = liste;
this.valeur = valeur;
this.index = index;
}
Now I want to store a keyset of my map, sorted by the float value from my class (valeur), in a LinkedList :
List<Integer> selection1 = new LinkedList(population1.keySet());
I know I could use Collection.sort to sort values and then track back their respective keys if those values were simple Strings or numbers, but I'm a little lost here. I feel there are simple and fast ways to do this without intermediate lists and variables. In addition, my code's execution needs to be as fast as possible (genetic algorithm for TSP).
SortedMapdoesn't work with sorting values.