This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Difference betwwen Sorted and Ordered Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Difference betwwen Sorted and Ordered" Watch "Difference betwwen Sorted and Ordered" New topic

Difference betwwen Sorted and Ordered

jaspreet atwal
Ranch Hand

Joined: Sep 05, 2007
Posts: 52

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


Still Learing..
Tejas V Shah

Joined: Mar 20, 2008
Posts: 20
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

Joined: Jun 05, 2008
Posts: 110
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)

I agree. Here's the link:
subject: Difference betwwen Sorted and Ordered
Similar Threads
Difference between sorted and ordered?
Ordered and Sorted
Collection Doubt
Is both Vector and Hashtable maintains object references in the order they were added?
ordered and sorted