• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sorted & Ordered

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do not understand what is ment by sorted & ordered of elements.
I am asking the question from Collection Topics.

can any body explain what is the difference between them with example.

thnx in advance.
 
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When a collection is said to be ordered if it can be iterated in a specific order.
Ex: ArrayList, but a Hashtable is not.

When a collection is said to be sorted if the values in it is sorted in a natural order. So when you are retriving the vaues you get it in sorted order. A sorted collection is also Ordered ..
ex: Treeset
[ December 20, 2005: Message edited by: Srinivasa Raghavan ]
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Srinivas,

Can u pls elaborate a little bit, more



Thanks,
Siva Prakash
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when you are using the ArrayList and the elements are retrieved in the order in which they are inserted into the list.(ordered but not sorted)

When you use a TreeSet you will have the elements in the specific order
(Eg:Integer objects are sorted in ascending), or in the way you specify

So sorted also means some type of ordering.
But ordering doesnot assure to be sorted.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic