java - Sort ArrayList by double values -


i have arraylist double values:

double distance = haversinealgorithm.haversineinkm(lat, lon,                     stop.getstoplat(), stop.getstoplon()); distancelist.add(distance); 

i can smallest value in list this:

int minindex = distancelist.indexof(collections.min(distancelist)); currentlist.get(minindex); //it smallest value element 

but have know second smallest value , third smallest value element too. don't know how.

i tried sort list this:

collections.sort(distancelist); 

but it's not working. mean last index of list isn't smallest or highest value.

is here can explain me how can solve ? :)

this code looks good:

int minindex = distancelist.indexof(collections.min(distancelist)); currentlist.get(minindex); //it smallest value element 

so since in sorted order, can smallest, 2nd smallest, , 3rd smallert value bying directly calling index.

    currentlist.get(0);     currentlist.get(1);     currentlist.get(2); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -