• Post Reply Bookmark Topic Watch Topic
  • New Topic

Compareto.  RSS feed

 
amit cha
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Below is the code which reads the file line by line and is stored in the arraylist..
now how can i sort the list using (compareTo)?? ...
By using Collection.sort the sorting is done..



[Added code tags - see UseCodeTags for details]







 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried just using Collections.sort? String already implements Comparable, so you don't need to do anything else unless you want a different sort order to the natural one.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!