When I first saw the Schwartzian transform it took me
a while to just decipher it (ok, I'm getting old). I
was writing similar code (i.e. calculating sort fields
once rather than during each compare), but obviously
I was using a lot of intermediate arrays & hashes. It
probably ran almost as fast (and certainly fast enough
for me). I didn't learn how to sort with the transform,
nor how to optimize, but rather how to unhinge my brain
from writing in C and think of the problem totally
differently, in perl.
If I were teaching sorting to a beginner, I'd teach them
how to write a compare function. The first one would
probably just (inefficiently) parse each line each time
it was compared. After that I'd piecemeal a transform
using intermediate arrays. Then if they could grok
that I'd finally present the
transform in it's simplest form (i.e. each element
would look somethine like
[ $sortable_date, $original_string ]
In certain limited forums I think "baby Perl" is ok. Books,
tutorials, college classes are all appropriate for this.
Past that they should be expected to use the available
resources (or be pointed to them). It
just amazes me that folks actually interview for jobs that
they would be, not just slightly, but totally incompetent in.
These people just don't have the "right stuff". The
"right stuff" here isn't knowing perl or being a programming
guru. It's the drive that pushes you to learn about it,
and the mental ability to actually be able to apply some
of it from time to time.
bluto
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.