[Tutor] how to sort the data inside the file.
Kent Johnson
kent37 at tds.net
Mon Dec 31 14:31:47 CET 2007
goldgod a wrote:
> hello all,
> Please find the attached file. I want to sort the content
> of this file based on the "bytes" in descending order. How can i do
> it, any pointers to it.
There are several things to do here:
- read the file
- split into records
- extract the byte count
- sort
- write the file in sorted order
Which parts are you having trouble with? What have you tried?
File reading and writing are covered in any Python tutorial. For the
sort, I would make a list of
( byte count, record )
and sort that using the list.sort() method.
Kent
More information about the Tutor
mailing list