wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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)

It is sorta covered in the JavaRanch Style Guide.
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