• 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 or ordered

 
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is different betwenn sorted and ordered when considering collection?
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at this...
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Slightly confusing link, but it does give the general direction.

People often use "sorted" and "ordered" rather loosely, but that link does tell you that it is possible to go through an ordered collection and retrieve the first-entered value first, then the second, etc. That link is confused about LinkedList and ArrayList, saying that you add to the end of a LinkedList and to the index in an ArrayList. It is usual to add to the end of an ArrayList, and it is possible to add to an index in a LinkedList. By inserting elements in the middle of a List, you are altering the order.

It is correct about "sorted"; you can get elements out in a sequence determined by their "values". You can alter the sequence of "values" by changing Comparators or a compareTo method or similarly.

You can also sometimes get Collections ordered backwards (eg a Stack) or iterate through collections backwards.
 
reply
    Bookmark Topic Watch Topic
  • New Topic