Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- f = open('nvccSalaryList.txt', 'r+')
- ('nvccSalaryList.txt', 'r+')
- ln = f.readline()
- usd_list = []
- while ln != '':
- if ln.find('$') != -1:
- usd_list.append(tuple(ln.split('$'))) #convert the list returned by .split() to a tuple and append it to the list
- ln = f.readline()
- sorted(usd_list, key=lambda usd: usd[1]) #sort by the second member in each tuple (the money)
- f2 = open('sortedNvccSalaryList.txt', 'r+')
- f2.write(str(usd_list))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement