''' # Python 2.3

fn = r'H:\TEMP\temsys\elements.txt'

data = [item.split() for item in open(fn).readlines()]

dataDict = dict(zip([float(i[1]) for i in data], [j[0] for j in data]))

print dataDict

 

keys = dataDict.keys()

keys.sort()

outList = [[dataDict[key], '%0.5f' % key] for key in keys]

print outList

'''

 

# Python 2.4

fn = r'H:\TEMP\temsys\elements.txt'

data = [item.split() for item in open(fn).readlines()]

dataDict = dict(zip([float(i[1]) for i in data], [j[0] for j in data]))

print dataDict

 

outList = [[dataDict[key], '%01.5f' % key] for key in sorted(dataDict.keys())]

print outList

 

''' Data

Ac 227.0

Ag 107.868

Al 26.98154

Am 241.1

Ar 39.948

As 74.9216

'''

 

'''

>>> {39.948: 'Ar', 227.0: 'Ac', 241.09999999999999: 'Am', 26.981539999999999: 'Al', 74.921599999999998: 'As', 107.86799999999999: 'Ag'}

[['Al', '26.98154'], ['Ar', '39.94800'], ['As', '74.92160'], ['Ag', '107.86800'], ['Ac', '227.00000'], ['Am', '241.10000']]

>>>

'''

 

'''

dataList = [[float(weight), elem] for elem, weight in [item.split() for item in data]]

dataList.sort()

print dataList

'''