• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how come Set is not sortable

 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

i was just wondering how come a List object is sortable using Collections.sort but a Set is not?

 
John de Michele
Rancher
Posts: 600
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not just use a SortedSet?

John.
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cuz i didnt know it exists ;)
thank you
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12015
24
Chrome Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A set in Mathematics by definition has no order. sometimes you may want a set that doesn't have the overhead of sorting.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic