isha krishnan wrote:if list in ascending or descending order
Well, what you are doing here is - invoking compareTo method of 'Songs'. Thus, it will be sorted according to Songs' class' compareTo method. That is, if Songs is a
String object, then you are invoking String class' compareTo method.
Now, if you want to reverse the logic, it can be simply done by modifying return statement to:
Regarding 'by default rules', yes there are - e.g. for Integer class, compareTo returns result of simple numeric comparison, for String class, compareTo returns result of alphabetic comparison and so on.
I hope this helps.
Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)