sorting data
Terry Reedy
tjreedy at udel.edu
Mon Oct 29 17:10:14 EDT 2007
"Beema shafreen" <beema.shafreen at gmail.com> wrote in message
news:aa405c1f0710290224gb307d45lf8aadf16055b1d0 at mail.gmail.com...
| hi all,
| I have problem to sort the data.. the file includes data as
| follow.
| file:
| chrX: 123343123 123343182 A_16_P41787782
[snip]
| how do is sort the file based on the column 1 and 2 with values......
| using sort option works for only one column and not for the other how do
is
| sort both 1 and 2nd column so that the third column does not change.....
| my script
If I understand correctly, the following untested version of your code
should do what you ask. Otherwise, you need to be more specific.
lis = []
fh = open('chromosome_location_346010.bed','r')
for line in fh.readlines():
data = line.strip().split('\t')
start = data[1].strip()
end = data[2].strip()
probe_id = data[3].strip()
lis.append((start,end),probe_id)
lis.sort()
tjr
More information about the Python-list
mailing list