Skip to content

Instantly share code, notes, and snippets.

@xguse
Created June 30, 2013 21:38
Show Gist options
  • Save xguse/5897045 to your computer and use it in GitHub Desktop.
Save xguse/5897045 to your computer and use it in GitHub Desktop.
example script to sort a file for seqanswers user marqudiego
import sys
in_file = sys.argv[1]
in_data = open(in_file, 'rU')
data_list = []
# separate and organize the data into fields
for line in in_data:
data_list.append([x.strip() for x in line.strip('\n').split('=')])
# convert the number parts to actual numbers vs strings
for each in data_list:
each[1] = float(each[1])
data_list.sort(key=lambda x: x[1])
for each in data_list:
print '%s = %s' % (each[0],each[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment