Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference betwwen Sorted and Ordered

 
jaspreet atwal
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Somebody please explain to me or direct me to somewhere I can understand how Sorted and Ordered are different.

Thanks!
 
Tejas V Shah
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jaspreet,

I found on net regarding difference between sort and order.

sort: To arrange (things, etc.) according to a kind or quality, or
after some settled order or system; to separate and put into
different sorts or classes.

order: The action of putting or keeping in order.

in order: In proper sequence or succession, according to rank,
importance, seniority, size, position, date, affinity, etc.
 
Antonio Tercero
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ordered : when a collection is ordered it means you can iterate through the collection in a specific order. An ArrayList is ordered by index.

Sorted : when a collection contains objects that are organized according to some rules. A TreeSet is a sorted collection because its elements are organized in ascending order(it has nothing to do with what position it was added at)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic