• 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

Ordering and Sorting

 
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can someone please explain me the difference between sorting and Ordering?
Both seems to be same and there is some difference..!! please explain with a real life example and relate it with Java..!!

Thanks in advance..!!!
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sunny Jain:
Both seems to be same and there is some difference..!!



What makes you think there is a difference ?
In general they are the same thing, but I guess it's possible, in certain contexts, that there might be subtle differences.
If you have been told, or have read, that there is a difference, then we would need to know the context in order to answer your question.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In usage, "sorting" is a verb (or at least, I have only seen it used as a verb). As for "ordering", it is a noun (although, I do remember seeing it used as a verb once).

In the context of english usage, maybe you concluded that they are different because they are used differently?

Henry
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Order" is overloaded in English...

I ordered some coffee, but my order came later than some later arrivals' orders. Ordering the disorderly orderly to my table, I told him that it was out-of-order for them to reorder the orders like that, and in order for me to reorder at their establishment again, an apology would be in order.
 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Well I got a good answer from one of my friend while chatting...he reminded me the 31st Dec, night:

We both were in the queue for entry in MOS (Ministry of Sound), So here we got some kind of Ordering..!! who so ever was coming..was joining us in the queue..now suppose if that time they would had announced please arrange yourself in the alphabetically Order ..then we will call it Sorting..So Sorting seems to be somewhat refined form of Ordering in Java context..!!!

But again it put one question in my mind..the Ordering was also time base sorting..???
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sunny Jain:
now suppose if that time they would had announced please arrange yourself in the alphabetically Order ..then we will call it Sorting



No - you'd call that arranging
[ January 23, 2008: Message edited by: Joanne Neal ]
 
Ranch Hand
Posts: 336
Firefox Browser Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sunny

Recently (yesterday exactly) i was studing about Collections on the book Kathy Sierra, where explain before deep in the specfic collection (List, Set, Map), what mean Sorted, Unsorted, Ordered and UnOrdered.

If I am no wrong (i hope not) i will tell you what i undertood.

1. Order, think on a sequence, for example. 1, 2, 3,

2. Sort, mean reorganizete that order or no order in one specific "criterio" <- sorry for the spanish word.

for example.

-You have a NoteBook, where star to write from the begining to the end.

-When you want to read the notebook, star from the beginig too. (HERE IS THE ORDER).

-but, mas adelante (sorry again) you noted that the order when you wrote the notebook is no appropiate and you decide to SORT by some "criterio" maybe for "Color of ink when you was writing" I dont know (HERE IS SORTED)

Onother example but of UNSORTED and UNORDER.

-The pants pocket, when you save the coins maybe you dont think so much and just insert coins to you pocket.

-And when you retrieve this coins from the pocket, neighter have a order, just go out randomly.

Another Thing. Sorted is one kind of Order.

...
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with Sunny's friend, and with Milton. Ordering and sorting (or ordered and sorted) are not the same thing. An ArrayList is ordered, which means that items in the List have a specific position which does not change unless someone specifically changes it. Most commonly, items are ordered in the order they were added to the list, and they stay in that order unless they are moved. However an ArrayList is not necessarily sorted. Sorting means you put items into a specific order which depends on some property or properties of the items. E.g. you can sort a list into alphabetical order (for one or more fields), or numeric order (for one or more fields) or some other order. You can't sort a list into insertion order unless "time of insertion" is one of the fields in the object.

An ArrayList is always ordered, but not necessarily sorted - unless you call Collections.sort().

A TreeSet is always sorted, and therefore always ordered as well - unless you change a value after it's been inserted, in which case you've broken the TreeSet, and you're an evil person who should be shot.

A HashSet is neither sorted nor ordered - or rather, it's sorted by the remainder of the hashcode, and the remainder can change depending on the capacity, so it's not advisable for anyone to pay attention to the order of a HashSet, and instead we consider it to be unsorted and unordered.
[ January 23, 2008: Message edited by: Jim Yingst ]
 
Deepak Chopra
Ranch Hand
Posts: 433
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So Overall we can say that:
/*****************************************************************************************/
Every Sorted sequence is Ordered, But Every Ordered sequence is not necessarily sorted.
/*****************************************************************************************/
 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Every Sorted sequence is Ordered, But Every Ordered sequence is not necessarily sorted.



I think I would say, "...has not necessarily been sorted".

Subtle difference, but I guess (on a purely semantic level), I would say that sorting is something that is done, ordering is something that just happens, either as a result of sorting (once you've sorted some things, they are in some order), or as a co-incidence (when people are standing in a queue, they, co-incidentally, are in chronological order).

Thinking about it, in English, things can be ordered, but I wouldn't say that I was 'ordering' something (in this sense, anyway), I'd always say that I was 'sorting', or 'putting in order'.
 
The glass is neither half full or half empty. It is too big. But this tiny ad is just right:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic