in reply to sort utility key specification

BrowserUk:

I occasionally need to sort financial files from mainframes, so I'd love to see flags for packed decimal fields. I have a script that I use to patch up these files into text for sorting, but it would be nice to skip that step.

Also, I don't know whether your n flag means that the sort routine expects binary values in your records, or text strings representing numbers. If it means your records contain binary values, I'd really like to sort a numeric text column in natural order:

unsorted sorted ---------- ---------- xxx1 xxx xxx1 xxx xxx11 xxx xxx 5 xxx xxx 5 xxx xxx 010xxx xxx010 xxx xxx11 xxx

Regarding your comment about gnu sort: I know what you mean. I use it infrequently enough that I can't remember just how to specify what I want, but often enough to wish it was easy to remember. I generally have to sort the file a few times before I can get the switches just right.

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^2: sort utility key specification
by BrowserUk (Patriarch) on Apr 21, 2012 at 14:01 UTC
    I'd love to see flags for packed decimal fields.

    Hm. I was under the impression that packed decimal fields sorted in correct numeric order when treated as strings?

    Also, I don't know whether your n flag means that the sort routine expects binary values in your records, or text strings representing numbers.

    Text representing numbers.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

      BrowserUk:

      They do, until you throw in some negative numbers. They munge the sign into the last character.

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

        They do, until you throw in some negative numbers. They munge the sign into the last character.

        Ah yes. That's a pain to deal with.

        I'll look into how much work is involved -- there is also the issue of implied decimal points -- relative to the number of times it might get used.

        One question. What type character would you use for bcd?

        'b' is currently free, though I can see it might be useful for something else. 'd' is used and 'c' isn't particularly mnemonic.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        The start of some sanity?