Possible Duplicate:
How to sort an arraylist of objects by a property?
What is the sorting algorithm for Java
I have a class in java that keeps record of diffSeconds
.
class fileObj
{
public String fileName;
public Date modificationTime;
public long diffSeconds;
fileObj()
{
modificationTime = null;
}
}
I have a forloop that makes multiple instances of the fileObj
class and adds them to a list.
List<fileObj> fileView = new ArrayList<fileObj>();
for(int j=0; j<10; j++)
{
fileView.add(new fileObj());
}
Assuming that each class has a diffSeconds
values assigned to them, how can i order the list depending on the value (largest first)