This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sort of collections by Collections.sort(..)

 
Pawanpreet Singh
Ranch Hand
Posts: 264
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We know that we can only do sort of List by Collections.sort,

We can not do sort HashSet, HashMap and Hashtable.....because they are uordered. But LinkHashSet and LinkedHashMap are there as ordered by insertion.

So could anybody tell me that can we sort LinkHashSet and LinkedHashMap also by some way.

Sincerely,
Pawan
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want sorted sets and maps go for TreeMap and TreeSet.
 
Pankaja Shinde
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no way
we can't change the functionality of LinkedHashSet and LinkedHashMap.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic