J
Jaba
Is there a clean way to sort an ArrayList loaded with Objects of a
class based on a variable within that object?
class based on a variable within that object?
See java.lang.Comparable, java.util.Comparator, and java.util.Collections.Jaba said:Is there a clean way to sort an ArrayList loaded with Objects of a
class based on a variable within that object?
Ryan Stewart said:See java.lang.Comparable, java.util.Comparator, and java.util.Collections.
Collections.sort(List) takes a list of objects that implement the Comparable
interface. Collections.sort(List, Comparator) takes a list of anything and a
Comparator that knows how to compare them.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.