Advertisement
Guest User

Untitled

a guest
Sep 21st, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. f = open('nvccSalaryList.txt', 'r+')
  2. ('nvccSalaryList.txt', 'r+')
  3. ln = f.readline()
  4. usd_list = []
  5. while ln != '':
  6. if ln.find('$') != -1:
  7. usd_list.append(tuple(ln.split('$'))) #convert the list returned by .split() to a tuple and append it to the list
  8. ln = f.readline()
  9. sorted(usd_list, key=lambda usd: usd[1]) #sort by the second member in each tuple (the money)
  10. f2 = open('sortedNvccSalaryList.txt', 'r+')
  11. f2.write(str(usd_list))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement