File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "sort  list values" Watch "sort  list values" New topic

sort list values

anvi kon
Ranch Hand

Joined: Jan 08, 2010
Posts: 133

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


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

How would I do that in java?


Jeff Verdegan

Joined: Jan 03, 2004
Posts: 6109

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!
I agree. Here's the link:
subject: sort list values
It's not a secret anymore!