aspose file tools*
The moose likes Beginning Java and the fly likes sort  list values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "sort  list values" Watch "sort  list values" New topic
Author

sort list values

anvi kon
Ranch Hand

Joined: Jan 08, 2010
Posts: 133
hi,

Can anyone help me to get the least values from the List?

Here is the code below.

List lst = getvalues(String s);

I have three values:lst.size() =3

150,25,250.

I need to sort it and get the lowest value 25.

How would I do that in java?

Thanks,





Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Do you have a requirement to sort the list? Or just to get the smallest value?

If all you want is the smallest value, there's no need to sort.

If you want to sort, then java.util.Collections has a sort() method that takes a List parameter, or, if you need to write your own, google for sorting algorithms or check your textbook.

Once you've clarified your actual requirements and taken your best shot, post again, showing your efforts and asking a more specific question than, "How do I sort?"

Good luck!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: sort list values