• Post Reply Bookmark Topic Watch Topic
  • New Topic

sort vector for a part of value  RSS feed

 
Abrahim Daver
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I sort a vector which has filesname with extension, but I want to sort it with extension. How can I do that.
For input as
abc.txt
abc.pdf
abc.doc
def.doc
def.txt
def.pdf
OutPut should be
abc.doc
def.doc
abc.pdf
def.doc
abc.txt
def.txt
How can I achieve this. Cany anyone help me out to do this.
Thanks,
Abra
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the method Collections.sort and use a Comparator.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!