
Why does sorting in computer science mean ordering rather than categorizing? - randomwalker
https://twitter.com/random_walker/status/1036704758696960001
======
randomwalker
OP here. The number and variety of special-purpose computing devices that
existed before general purpose computers is astounding. The surprising (to me)
conclusion is that the main impediment to the development of computers wasn't
technology. After all, Babbage's machine could have been built in his time if
funding hadn't run out.

Rather, the limitation was that people didn't have the abstractions,
vocabulary, and mental tools to properly conceive of general purpose computers
as a concept and to understand their usefulness. They couldn't see that
devices as seemingly disparate as tide prediction machines[1], census
tabulation machines, and loom controllers were all instances of a single,
terrifyingly general idea.

From what I can tell, Babbage mostly understood this, but it was Ada Lovelace
who grasped it fully. But her writings weren't understood in her time and had
to be "rediscovered" a century later. For example, she wrote [2]:

 _Supposing, for instance, that the fundamental relations of pitched sounds in
the science of harmony and of musical composition were susceptible of such
expression and adaptations, the engine might compose elaborate and scientific
pieces of music of any degree of complexity or extent._

This leads me to wonder: what abstractions are we missing today that will be
obvious to future generations?

BTW I have a follow-up thread on the optical telegraph, a form of networking
that long predates the Internet. [3] My long-term goal is to teach a course on
computing/networking/information processing before computers, with a view to
extracting lessons that are still applicable today.

[1] [https://en.wikipedia.org/wiki/Tide-
predicting_machine](https://en.wikipedia.org/wiki/Tide-predicting_machine)

[2] [https://googleblog.blogspot.com/2012/12/honouring-
computings...](https://googleblog.blogspot.com/2012/12/honouring-
computings-1843-visionary.html)

[3]
[https://twitter.com/random_walker/status/1037031465735860224](https://twitter.com/random_walker/status/1037031465735860224)

~~~
garmaine
> After all, Babbage's machine could have been built in his time if funding
> hadn't run out.

Funding ran out in large part because of cost overruns due to the fact that
the technology of the time wasn’t capable of building the analytic engine
design.

~~~
randomwalker
That's possible, but an alternative explanation for the cost overruns that
I've read is that Babbage had terrible project management skills.

Wikipedia has this to say:

 _In 1991, the London Science Museum built a complete and working specimen of
Babbage 's Difference Engine No. 2, a design that incorporated refinements
Babbage discovered during the development of the Analytical Engine. This
machine was built using materials and engineering tolerances that would have
been available to Babbage, quelling the suggestion that Babbage's designs
could not have been produced using the manufacturing technology of his time._

[https://en.wikipedia.org/wiki/Analytical_Engine](https://en.wikipedia.org/wiki/Analytical_Engine)

~~~
chubot
I just finished reading The Difference Engine yesterday, an entire book about
this project, by the project lead!

[https://www.amazon.com/Difference-Engine-Charles-Babbage-
Com...](https://www.amazon.com/Difference-Engine-Charles-Babbage-
Computer/dp/0142001449)

(unfortunately overshadowed in Google Search results by a William Gibson book
of the same name)

It gives a lot of color on Babbage, but yes the conclusion was that Babbage
design basically worked, and could have been built. There were errors in his
drawings that they had to correct, but nothing fundamental.

The group at the Science Museum spent over 6 years doing this! This is the
group that holds most of his papers, drafts, and unfinished machines.

Although there are a couple things I want to follow up on. They weren't that
specific about what computation they did. And does it still work today? It was
extraordinarily finicky. It produced a lot of bit errors, as did mechanical
computing devices that came later, which sort of defeated the purpose (it was
supposed to calculate tables of logarithms and such with higher accuracy than
humans.)

~~~
azernik
The examples built do indeed keep on working with non-prohibitive maintenance
- the 2nd #2-design engine (built in the 2000s for Nathan Myhrvold), was on
display at the CHM in Mountain View for 8 years with daily or twice-daily
demonstration runs. It sadly went off display in 2016 (probably to go to
Myhrvold's private collection) but I saw the demonstration a couple of times
and can answer some of your questions:

1\. The concrete computation performed was to use the Finite Difference Method
([https://en.wikipedia.org/wiki/Finite_difference_method](https://en.wikipedia.org/wiki/Finite_difference_method)
\- hence the "Difference Engine" name) to calculate arbitrary polynomials of
degree up to IIRC 10. By using Taylor Series, this method could be used to
calculate arbitrary functions, like log and sine. This was in fact the same
method used to construct logarithmic tables by hand at the time, and had
similar nominal precision; the singular goal was to eliminate the bit errors
rampant in the old, manual process.

2\. The machine removed not just errors in calculation, but also in
typesetting; about half the part-count of the original design was in its
printer, which could be configured with all kinds of options for typesetting
the results. It would output a "print preview" onto paper locally (this was
not publicly demonstrated at the CHM because of the enormous mess of ink
spills, but the machinery _was_ run dry), and an identical wax mold ready for
use in mass printing. This was because many of the bit errors in the existing
log/sine/etc. tables were introduced not by the (human) computers, but by the
multiple copying steps involved in transforming calculated values into printed
pages.

3\. Computation was quite reliable - the machine worked in base 10, and
mechanisms were carefully designed to freeze up (and be easily resettable to a
known-good state, as demonstrations showed) before introducing errors. As far
as I know bit errors were unheard of in the demonstration runs. This
reliability, like in later electronic computation, was the motivation for
using digital rather than analog logic. (Finickiness was mostly limited to
those halting conditions - it proved quite sensitive to clock speed (rate of
crank turn), but only by the standards of the hand cranking used in
demonstrations; connected up to a steam engine with 19th-century rate
governors, input power could have been kept clean enough to run with long
MTTF.)

~~~
gugagore
Thanks for those details. I am glad to have seen the demonstration. I didn't
know they removed it in 2016.

I believe the better link is
[https://en.wikipedia.org/wiki/Divided_differences](https://en.wikipedia.org/wiki/Divided_differences)

------
outsidetheparty
Maybe it's just because I've spent too long with computers, but I thought the
everyday meaning of "sorting" _was_ ordering, not categorizing.

(Though now that I think about it, it's both: if I handed a random non-coder a
deck of cards and asked them to sort them, I'd expect them to group by suit
and then order by value. I wouldn't expect four stacks by suit in random
order, or a deck of all the cards in numerical order regardless of suit...)

That nitpick aside, it was a good excuse to get into the interesting pre-
digital computing history stuff.

~~~
o_nate
I had the same initial reaction, but the dictionary supports the idea that the
everyday usage of sort means to group by category, not to order. I've probably
just been coding too long as well.

~~~
alanbernstein
Are you referring to a dictionary of word definitions? The kind that is
structured as a list of words, ordered lexicographically? Where is the
categorization in that?

~~~
mort96
What do you mean? I agree that dictionaries are ordered and not categorized,
but do dictionaries claim to be sorted?

~~~
alanbernstein
I thought parent was using "the sortedness of dictionaries" as his argument, I
now realize he meant "the dictionary definition of 'sort'".

------
wodenokoto
These "twitter stories" are horrible to read.

Someone else posted a much more readable version, but it is buried under a
downvoted post:

[https://threadreaderapp.com/thread/1036704758696960001.html](https://threadreaderapp.com/thread/1036704758696960001.html)

------
johannes1234321
This is quite interesting. From my German background I associate "sortieren"
with alphabetic/numerical /calendaring order. Whereas "ordnen" ist more like
"putting in order"/"categorize" or "sorting". So maybe it's as easy as blaming
the Germans ;-)

~~~
jdmichal
Except that _-ieren_ ending on _sortieren_ is indicative of an import from
Romantic languages, typically French or Italian. [0] So it's likely that the
English and German word both share French _sortir_ as an imported root.
Etymonline lists it as 14th century English, so too late to have inherited it
through German. [1]

[0]
[https://en.wiktionary.org/wiki/-ieren#German](https://en.wiktionary.org/wiki/-ieren#German)

[1]
[https://www.etymonline.com/word/sort#etymonline_v_24299](https://www.etymonline.com/word/sort#etymonline_v_24299)

~~~
anticensor
> Except that -ieren ending on sortieren is indicative of an import from
> Romantic languages, typically French or Italian.

Except that it is Romance or Romanic languages, not Romantic languages.

~~~
em-bee
although french and italian are seen as romantic by some :-)

------
kazinator
Sorting is categorizing, just with an order imposed on the categories.

If the categories have a natural order, then people will exploit that when
they sort.

Suppose you had to put some cards with names on them into bins labeled by
first letter. You might go through the cards one by one and stick each in the
appropriate bin. It would help you if the bins are in alphabetic order, rather
than scrambled.

Sorting into categories involves a search to find the category for an item;
the search benefits from order.

~~~
hk__2
> Sorting is categorizing, just with an order imposed on the categories.

…and infinite categories.

~~~
jdmichal
Infinite, or recursive? Alphabetic, lexographic, and numeric sorts are
recursive over "significant digits", which is why we can write radix sorts.
(Scare quotes because that term doesn't necessarily directly translate to
alphabetic and lexographic sorting, but the basic prinicple is the same.)

~~~
solipsism
"recursively" is but one way to build a potentially infinite set. They're not
mutually exclusive.

------
adamzochowski
Soundex, the word similarity hashing algorithm, also predates computers. It
was developed in early 1900, to help perform census in USA. One of its goals
was to sort similar last names together.

[https://en.wikipedia.org/wiki/Soundex](https://en.wikipedia.org/wiki/Soundex)

------
Isamu
Knuth discusses this in Vol 3 Sorting and Searching ... we mean "collate" by
sorting. Unfortunately I don't have that volume at hand to quote. Anybody?

~~~
sp332
> 5.2.4 Sorting by Merging

> _Merging_ (or _collating_ ) means the combination of two or more ordered
> files into a single ordered file.

So it's not quite the same idea.

------
codazoda
I dunno... phonebooks we're sorted alphabetically before they were created
with computers. That's a single sorted list and not a set of categories. The
card sorting is interesting but it seems like the word is simply used in
multiple ways.

~~~
jwfxpr
Phonebooks are in alphabetical _order_. They are _sorted_ into residential and
business (white and yellow), then further _sorted_ into business categories
(or in some cases residential areas), and then _ordered_.

------
bagrow
If you decorate each item with a category tag and then sort using those tags,
you are categorizing. The power of decorate-sort-undecorate.

------
larrik
This is great stuff, too bad it's on Twitter instead of a real website or
platform.

~~~
X6S1x6Okd1st
Regardless of if you like twitter or their practices they are a real website
and platform.

~~~
bcaa7f3a8bbc
I agree.

I hate to post anything longer than random thoughts on Twitter, but this is an
unfortunate consequence of the culture shift in past 10 years driven by the
social media giants. Like it or not, Twitter is now the center of gravity of
the entire Internet, and currently the most effective online platform to make
posts with high visibility is Twitter...

Other platforms like forums declined, even forums did nothing wrong by
themselves, and they are in fact much more suitable for real discussion. But
the culture is already changed, people got used to make random 20 words posts
on their mobile phones instead of reading a long threads of discussion,
microblog-like, social-media-like platforms would prevail in the shortterm
future. The only thing we can do is to promote a OStatus-based, open,
alternative social media implemented by GNU/Social, Mastodon, etc, to make the
situation less harmful.

I'm happy that we can still have real discussion on Hacker News.

~~~
marssaxman
_Twitter is now the center of gravity of the entire Internet_

Journalists and celebrities certainly seem to think so, and I'm glad they do,
because I can easily avoid them by simply ignoring Twitter.

~~~
mirimir
Same here. Maybe if there were decent tools for aggregating and filtering. But
there aren't.

------
billfruit
Some words do have different meaning in computer science, as is the case with
other fields as well.

Perhaps a more illustrative example is the word "or", in plain english it
normally means an "exclusive or", but in CS it means an "inclusive or".

------
dexen
Consider the following four combinations of {stable, unique}:

\- _stable sort of unique values_ is ordering

\- _stable sort of non-unique values_ is categorization + ordering; this is a
most general algorithm which could reasonably be used for either operation

\- _non-stable sort of non-unique values_ is categorization without ordering

\- _non-stable sort of unique values_ technically could be implemented as a
NOP.

Given that various strategies of ordering and categorizing have different
trade-offs between {memory,computational} complexity, and linear vs random
access patterns, it makes sense to consider them pluggable algorithms that can
be swapped depending on requirements.

------
anonytrary
"That sort of person would sort the blocks into buckets" uses "sort" twice
(differently) without implying some underlying metric for "people" or "blocks"
and it's pretty clear in context. I saw a few people in the comments say they
are surprised that "sort" would be used that way, but I'd bet money that they
understood my example correctly.

"The blocks were sorted by size" implies that there is some metric, and again,
it's pretty clear in context.

------
admax88q
Holy hell do I hate reading articles as a series of tweets.

~~~
icc97
The OP says it was just a random collection of thoughts rather than an
article. He's going to turn them into a proper blog post.

------
femto
> If the electric telegraph hadn’t been invented, would engineers have
> continued to optimize the optical telegraph?

Isn't that today's Free Space Optical Communications? Bandwidth is measured in
Gigabits per second.

[https://en.wikipedia.org/wiki/Free-
space_optical_communicati...](https://en.wikipedia.org/wiki/Free-
space_optical_communication)

------
jancsika
I'm not sure what the difference is in sorting by category vs. order.

For example, consider an array of one million arbitrary alpha-numeric strings.
If you were to sort them by category, would that mean simply making contiguous
regions of the array where each string begins with the same character?

------
olejorgenb
Assoc: Edge-notched cards - [https://kk.org/thetechnium/one-dead-
media/](https://kk.org/thetechnium/one-dead-media/)

------
jalayir
Ordering is just a special case of categorizing.

~~~
wyattpeak
I'd say it's arguably a degenerate case, but it's very arguable.

Few people would claim that each position in an order is a different category.
And if I asked someone to categorise a pile of papers and they handed me back
a single stack, I'd be unimpressed.

------
acct1771
Ordering is categorizing organized into a vertical grid.

------
rjurney
In MapReduce, they're the same thing.

------
nixpulvis
Yawn, words mean things in context... yada yada.

That said, the details about old school punch card sorting is pretty neat.

------
fiftyfifty
That's exactly what bucket sort is. Don't they teach that in Comp Sci anymore?

