Sort lines in a text file

leegold goldtech at worldpost.com
Sun Jul 22 18:53:58 EDT 2007


...snip...
> To save anybody who's tempted to write the whole shebang for you,
> please specify which part(s) of the exercise you are having problems
> with:
> (a) reading lines from a file
> (b) extracting a sort key from a line [presuming "number" means
> "positive integer"; what do you want to do if multiple lines have the
> same number? what if no number at all"]
> (c) creating a list of tuples, where each tuple is (key,
> line_contents)
> (d) sorting the list
> (e) creating the output file from the sorted list.

Thanks, you've done more than enough right here!

(a) through (e) gives me a good start.

Again, thank you for this.




More information about the Python-list mailing list