---------------------------------------- > Date: Wed, 27 Jan 2016 02:24:35 +1100 > From: st...@pearwood.info > To: tutor@python.org > Subject: Re: [Tutor] Why is an OrderedDict not sliceable? > > On Sun, Jan 24, 2016 at 07:47:47PM +0000, Albert-Jan Roskam wrote: > >>> You appear to be confusing ordered and sorted. >> >> You are correct. Is there a difference in the way those terms are >> used colloquially vs. in the field of Computer Science (Note: English >> is not my mother tongue)? > > In ordinary English, "ordered" and "sorted" often are used to mean the > same thing. People do often use sorted and ordered as interchangeable, > but the definitions are slightly different: > > > > ordered \ordered\ adj. > 1. having or evincing a systematic arrangement; especially, > having elements succeeding in order according to rule; as, > an ordered sequence; an ordered pair. Opposite of > disordered or unordered. [Narrower terms: > abecedarian, alphabetical; {consecutive, sequent, > sequential, serial, successive ] > [WordNet 1.5 +PJC] > > 2. arranged in order. > > Sort \Sort\, v. t. [imp. & p. p. Sorted; p. pr. & vb. n. > Sorting.] > 1. To separate, and place in distinct classes or divisions, > as things having different qualities; as, to sort cloths > according to their colors; to sort wool or thread > according to its fineness. > [1913 Webster] > > > The way I would put it is that "sorted" means the items are ordered > according to some specific rule or property of the items themselves, > e.g. to sort your clothes by colour. "Ordered" is more general: it just > means to have some order, which may be according to a rule or property, > or it may be in whatever sequence the items happen to have. > > Books on a shelf have some order, the order that they appear when you > read them from left to right, regardless of whether they are sorted by > author, title, height, colour or at random. Books jumbled up in a bag > have no order. > > Ordinary dicts are like books in a bag. You reach in and grab whatever > book happens to come to hand first. OrderedDicts are like books on a > shelf: you can systematically touch each book in order starting from the > left, and new books are always added to the right.
Thank you! That distinction is indeed quite subtle. With "ordered" I tend to think of "ordinal measurement level" or something like that. E.g., sort a list of heights, calculate the median, ntiles etc. But your description makes it a whole lot clearer. Sometimes analogies work better! _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor