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

Re: [OT] question regarding sort(1)



On Sun, 2003-01-26 at 11:40, Steve Juranich wrote:
> On 26 January 2003 at 10:37,
> Ron Johnson <ron.l.johnson@cox.net> wrote:
> 
> > What I want, though, is a straight, dumb ASCII sort based on each whole
> > line of text, where " " collates before "0", etc.  I've looked in the
> > man page, but see nothing.

Here's an example:

$ sort sort.example.txt
  10,040,583  Violin_Concerto_in_D_major_Op._35.mp3
  10,056,845  Symphony_5_Allegro_con_brio.mp3
  10,101,975  MARS,_The_Bringer_of_War.mp3
   1,011,879  rudolph's finale,instrumental.mp3
  10,150,230  track_15.mp3
   1,016,476  track 10.mp3
  10,191,633  Moonlight_Sonata_Presto_agitato.mp3
   1,019,494  track_22.mp3
       1,019  rip.ama.sh
   1,024,000  track 32.mp3
  10,303,836  Memory_Motel.mp3
  10,331,203  Track_9.mp3
  10,351,528  The_Long_Road_Back.mp3
  10,394,167  Don_Giovanni_K_527_-_a_cenar_teco_minvitasti.mp3
   1,041,972  belle (reprise).mp3
  10,485,888  notes - prima donna.mp3
  10,524,581  Flower_waltz_from_The_Nutcracker.mp3
   1,055,346  track 10.mp3
   1,061,527  Two-Part_Invention_No._10_in_G_Major,_BWV_781.mp3
   1,061,616  track 07.mp3
   1,067,049  monkey chase.mp3
   1,068,303  track 24.mp3

Since " " collates before "1", I think it should sort to:
       1,019  rip.ama.sh
   1,011,879  rudolph's finale,instrumental.mp3
   1,016,476  track 10.mp3
   1,019,494  track_22.mp3
   1,041,972  belle (reprise).mp3
   1,055,346  track 10.mp3
   1,061,527  Two-Part_Invention_No._10_in_G_Major,_BWV_781.mp3
   1,061,616  track 07.mp3
   1,067,049  monkey chase.mp3
   1,068,303  track 24.mp3
  10,040,583  Violin_Concerto_in_D_major_Op._35.mp3
  10,056,845  Symphony_5_Allegro_con_brio.mp3
  10,101,975  MARS,_The_Bringer_of_War.mp3
  10,150,230  track_15.mp3
  10,191,633  Moonlight_Sonata_Presto_agitato.mp3
  10,303,836  Memory_Motel.mp3
  10,331,203  Track_9.mp3
  10,351,528  The_Long_Road_Back.mp3
  10,394,167  Don_Giovanni_K_527_-_a_cenar_teco_minvitasti.mp3
  10,485,888  notes - prima donna.mp3
  10,524,581  Flower_waltz_from_The_Nutcracker.mp3

The Python sort() method sorts the way I expect it to, btw, but
I'd rather use a standard tool.

> I guess I'm not quite clear on what you want, but as I see it there's 
> only two ways to do this:
> 
> quail (sjuranic)$ cat text
> 1
> [snip]
> 1001
> 
> Unless you want something really strange, like "2" to come before "200" 
> but after "1000" (in which case you'll probably have to roll your own).

-- 
+---------------------------------------------------------------+
| Ron Johnson, Jr.        mailto:ron.l.johnson@cox.net          |
| Jefferson, LA  USA      http://members.cox.net/ron.l.johnson  |
|                                                               |
| "Fear the Penguin!!"                                          |
+---------------------------------------------------------------+



Reply to: