def dict2bibtex(d):
	""" Simple function to return a bibtex entry from a python dictionary """
	outstring =  '@' + d.get('TYPE','UNKNOWN') + '{' + d.get('KEY','') + ',\n'
	kill_keys = ['TYPE','KEY','ORDER']
	top_keys = ['AUTHOR','TITLE','YEAR']
	top_items = []
	rest_items = []
	for k in d.keys():
		if k in top_keys:
			top_items = top_items + [ ( k , d[k] )]
		elif not k in kill_keys:
			rest_items = rest_items + [ ( k , d[k] )]
	rest_items.sort()
	for k in top_items + rest_items:
		outstring = outstring + '\t' + k[0] + ' = {' + k[1] + '},\n'
	outstring = outstring +  '}\n\n'
	return outstring