"Newbie" questions - "unique" sorting ?

Cousin Stanley CousinStanley at hotmail.com
Thu Jun 19 15:53:26 EDT 2003


| ...
| (B) I am wanting to sort words (or is that strings ?)
| into a list from a clipboard and/or file input and/or....
|
| (C) To sort out the list of "unique" words/strings.
| ...

John ...

Since maybe I helped to steer you toward Python,
maybe I can help to keep you interested ...

I came up with a version that ....

    o splits lines into word lists as suggested

    o sorts them using Erik's lambda expression

    o eliminates duplicates using a two-pass mechanism
      where the sorted duplicates file output from 1st pass
      is read in to eliminate duplicates in a 2nd pass
      using a simple test relying on the fact
      that the input list has been previously sorted ...

http://fastq.com/~sckitching/Python/word_list.zip
[ 2 KB ]

    Contains ...

        [ program | source_file | dups_file | target_file ]

The file names are hard-coded in the program,
but should be easy to edit or change to arguments ...

The dups_file could be deleted when finished with it
at run-time from the program if desired ...

The only source_file input that I tested it on
is an edited version of the one you posted here,
so the testing is limited ...

-- 
Cousin Stanley
Human Being
Phoenix, Arizona






More information about the Python-list mailing list