"Newbie" questions - "unique" sorting ?
CousinStanley at hotmail.com
Thu Jun 19 21:53:26 CEST 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.
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 ...
[ 2 KB ]
[ 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 ...
More information about the Python-list