in reply to Re^2: Reformat Text File
in thread Reformat Text File

> This assumes that the keys are in sorted order

What makes you say that?

Replies are listed 'Best First'.
Re^4: Reformat Text File
by ikegami (Patriarch) on Oct 05, 2004 at 17:36 UTC
    bah,valueA foo,valueB foo,valueC bar,valueD

    results in

    bah,valueA bar,valueD foo,valueB,valueC

    and not

    bah,valueA foo,valueB,valueC bar,valueD

    Therefore, merlyn assumes they are sorted (or assumes the order of the lines in the result doesn't matter, but then why call sort?).

Re^4: Reformat Text File
by tall_man (Parson) on Oct 05, 2004 at 20:17 UTC
    I presume the problem has been simplified from an original case with meaningful keys in some meaningful order. Say the keys were dates in some odd format:
    July 21,Milestone meeting August 3,First walkthrough August 3,Committee meeting September 12,Second walkthrough
    merlyn puts all the values into a hash and then does a straight sort on the keys. That would make "August 3" come before "July 21" in my example. Rather than work out a fancy sorting routine for dates (or whatever the keys might be), my example maintains the original order of the first appearance of each key.