[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: not wanting to delete somebody's home directory

On 2019-07-06, songbird <songbird@anthive.com> wrote:
> Curt wrote:
>> On 2019-07-05, mick crane <mick.crane@gmail.com> wrote:
> ...
>>> I'm incrementing the number by the loop and some software sees 2 as 
>>> bigger that 10 or something like this. I can probably get around that by 
>> Not sure exactly what you mean by some software, but you must be sorting
>> lexicographically (the numbers are treated as strings, in which case
>> alphabetically speaking 1 goes before 2).
>> I don't think anybody's pointed this out yet (to my surprise) so I
>> thought I would (maybe I missed it), although my ignorance is nearly
>> total in the matter.
>   i have no perl programming experience so i could
> not speak to that issue.

This wasn't a criticism of anyone but rather an observation.

In the bash shell I have wondered about this sorting "anomaly" myself and so
looked it up this very day. As the simple (and pretty obvious, really) answer
was completely amenable to my intellectual powers, I was kind of enjoying
myself believing I'd mastered a trivial programming concept and wished to share
my joyful discovery with the group. That it happened to be the result of the
OP's explicit interrogation and so proves itself to be on-topic is a matter of
pure serendipity.


# sort numerically ascending
my @articles = sort {$a <=> $b} @files;
# sort numerically descending
 my @articles = sort {$b <=> $a} @files;

The default must be to sort lexicographically.

>   songbird

"These findings demonstrate that under appropriate conditions the isolated,
intact large mammalian brain possesses an underappreciated capacity for
restoration of microcirculation and molecular and cellular activity after a
prolonged post-mortem interval." From a recent article in *Nature*. Holy shit. 

Reply to: