Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sort song titles

 
Cynthia Yeo
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can i sort the titles of the songs in descending order by using String.comparTo() method?
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Collections.sort(songs, Collections.reverseOrder());
Assuming that "songs" is a List of song titles or Song objects that have a sensible natural ordering. If not, then please tell us a bit more about your problem.
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic