Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #210841

Re: not wanting to delete somebody's home directory

From David Wright <deblis@lionunicorn.co.uk>
Newsgroups linux.debian.user
Subject Re: not wanting to delete somebody's home directory
Date 2019-07-06 17:20 +0200
Message-ID <ygUDL-6pL-1@gated-at.bofh.it> (permalink)
References (1 earlier) <ygzpD-2fB-1@gated-at.bofh.it> <ygAvn-2Qy-7@gated-at.bofh.it> <ygOoF-2J7-3@gated-at.bofh.it> <ygQJP-4bW-1@gated-at.bofh.it> <ygS8V-4Sy-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sat 06 Jul 2019 at 12:31:25 (-0000), Curt wrote:
> 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.

Um, typically the default sorting method is by the underlying binary
representation of the characters. Anything else means that some
interpretation of the semantics is taking place, eg folding the
cases together, ignoring punctuation, interpreting strings of digits
as numbers, honouring multipliers like k/M/G, interpreting combining
characters, and of course maltreating the binary characters as 8-bit bytes.

It wasn't clear to me where the OP was intending to sort: within perl
or in the shell. As I posted, my recommendation was to rename the
files within perl, but after they've all been generated, in order that
the number of files (and hence the number of digits required) is known.

Cheers,
David.

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

not wanting to delete somebody's home directory mick crane <mick.crane@gmail.com> - 2019-07-05 17:30 +0200
  Re: not wanting to delete somebody's home directory Greg Wooledge <wooledg@eeg.ccf.org> - 2019-07-05 17:30 +0200
    Re: not wanting to delete somebody's home directory mick crane <mick.crane@gmail.com> - 2019-07-05 17:40 +0200
      Re: not wanting to delete somebody's home directory The Wanderer <wanderer@fastmail.fm> - 2019-07-05 17:40 +0200
        Re: not wanting to delete somebody's home directory Greg Wooledge <wooledg@eeg.ccf.org> - 2019-07-05 17:50 +0200
          Re: not wanting to delete somebody's home directory The Wanderer <wanderer@fastmail.fm> - 2019-07-05 18:20 +0200
            Re: not wanting to delete somebody's home directory Greg Wooledge <wooledg@eeg.ccf.org> - 2019-07-05 19:00 +0200
              Re: not wanting to delete somebody's home directory The Wanderer <wanderer@fastmail.fm> - 2019-07-05 19:30 +0200
      Re: not wanting to delete somebody's home directory mick crane <mick.crane@gmail.com> - 2019-07-05 17:40 +0200
  Re: not wanting to delete somebody's home directory songbird <songbird@anthive.com> - 2019-07-05 18:40 +0200
    Re: not wanting to delete somebody's home directory john doe <johndoe65534@mail.com> - 2019-07-05 19:40 +0200
      Re: not wanting to delete somebody's home directory Greg Wooledge <wooledg@eeg.ccf.org> - 2019-07-05 20:00 +0200
    Re: not wanting to delete somebody's home directory mick crane <mick.crane@gmail.com> - 2019-07-05 19:50 +0200
      Re: not wanting to delete somebody's home directory David Wright <deblis@lionunicorn.co.uk> - 2019-07-05 21:10 +0200
        Re: not wanting to delete somebody's home directory mick crane <mick.crane@gmail.com> - 2019-07-05 23:00 +0200
      Re: not wanting to delete somebody's home directory Curt <curty@free.fr> - 2019-07-06 10:40 +0200
        Re: not wanting to delete somebody's home directory songbird <songbird@anthive.com> - 2019-07-06 13:10 +0200
          Re: not wanting to delete somebody's home directory Curt <curty@free.fr> - 2019-07-06 14:40 +0200
            Re: not wanting to delete somebody's home directory Wolf Halton <wolf.halton@gmail.com> - 2019-07-06 15:10 +0200
            Re: not wanting to delete somebody's home directory rhkramer@gmail.com - 2019-07-06 16:30 +0200
              Re: not wanting to delete somebody's home directory "Thomas Schmitt" <scdbackup@gmx.net> - 2019-07-06 17:40 +0200
                Re: not wanting to delete somebody's home directory "Jeremy Nicoll" <jn.ml.dbn.25@letterboxes.org> - 2019-07-06 18:10 +0200
            Re: not wanting to delete somebody's home directory David Wright <deblis@lionunicorn.co.uk> - 2019-07-06 17:20 +0200
    Re: not wanting to delete somebody's home directory mick crane <mick.crane@gmail.com> - 2019-07-05 20:00 +0200
      Re: not wanting to delete somebody's home directory mick crane <mick.crane@gmail.com> - 2019-07-05 21:10 +0200
  Re: not wanting to delete somebody's home directory David Christensen <dpchrist@holgerdanske.com> - 2019-07-05 22:30 +0200

csiph-web