• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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: 9708
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: 79705
381
  • 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.
 
Yeah, but how did the squirrel get in there? Was it because of the tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic