#341 Address System 'SORT' issue

closed-duplicate
Mark Hessling
5
2012-10-16
2011-02-02
Anonymous
No

I have a routine that reads in data from a file, creates a bunch of stem variables, then calls the Windows SORT command to, um, sort them.
For reasons I can't fathom, it randomly gives me back fewer records than I put into it.

I would be delighted to be shown where in my code I'm doing something wrong. Here's a snip of the code:

<create stem variables called oline.<n>

oc = oline.0 /* Set number of records I want to SORT */
Address System 'SORT' With Input Stem oline. Output Stem sline.

If oc <> sline.0 Then Do
Say "AARGH, SORT has mangled the data again"
Say "Records in was "oc", records back from sort was "sline.0
Exit 99
End

I can run it again and again and again (and again) and eventually it will work - although it can take any number of attempts from 1 to 20 (or more, may more...) before number of input records equals the number of sorted records. The number returned by SORT seems to be random, it's definitely not the same each time,

Any ideas ? I can forward on the whole program if someone has the heart to look through it...

Thanks in advance
Nick Varley - nick.varley@metron.co.uk

Discussion

  • Phil Downs
    Phil Downs
    2011-02-09

    If you already have the data in a stem, then I've had no problems using SysStemSort e.g.
    rc=sysstemsort(stem,ascending,sensitive,1,stem.0,1,1)
    if rc <>0 then do ; say 'Sort Failure' ; exit 1 ; end
    I've been able to make this 'simple' sort do some qite tricky sorts by making up a suitable key and prepending each stem variable, then after the sort trim it off again if you need to. If you give some thought to your key then you shouldn't have any problems.

     
  • Mark Hessling
    Mark Hessling
    2012-10-14

    Duplicate of 3400513 which will have a solution in v3.7

     
  • Mark Hessling
    Mark Hessling
    2012-10-14

    • status: open --> pending-duplicate
     
  • Mark Hessling
    Mark Hessling
    2012-10-16

    • status: pending-duplicate --> closed-duplicate