What is the difference between an ordered and a sorted collection?

Is there any difference between a sorted and an ordered collection?


An ordered collection means that the elements of the collection have a specific order. The order is independent of the value. A List is an example.

A sorted collection means that not only does the collection have order, but the order depends on the value of the element. A SortedSet is an example.

In contrast, a collection without any order can maintain the elements in any order. A Set is an example.


An ordered collection maintains the order of the elements based on the sequence you put stuff into/remove them from the collection.

A sorted collection keeps the elements sorted based on a sort criteria.


Java uses "ordered collection" to mean a collection such as List, where (unlike HashSet), the collection remembers what order the elements are supposed to be in. So elements can be added to the collection at a particular "place" in the order.

Java uses "sorted collection" to mean a collection such as SortedSet, where (unlike List), the order that the iterator traverses the collection is in accordance with a specified Comparator or the natural order of the elements.

So the difference is whether the ordering depends on the values ("sorted"), or is a property that elements have independently of their value ("ordered").