Just use a new dictionary with the merged lists sorted by priority to hold each dict in the merged list:
li1=[{'shape': 'square', 'color': 'red', 'priority': 2},
{'shape': 'circle', 'color': 'blue', 'priority': 2},
{'shape': 'triangle', 'color': 'green', 'priority': 2}]
li2=[{'shape': 'square', 'color': 'green', 'priority': 3},
{'shape': 'circle', 'color': 'red', 'priority': 1}]
res={}
for di in sorted(li1+li2, key=lambda d: d['priority']):
res[di['shape']]=di
print res.values()
Prints:
[{'color': 'blue', 'priority': 2, 'shape': 'circle'},
{'color': 'green', 'priority': 3, 'shape': 'square'},
{'color': 'green', 'priority': 2, 'shape': 'triangle'}]
Since this is a dictionary with uniques keys, the last items of a given shape will replace the earlier items with the same shape. Since the items are sorted by priority, {'shape': 'square', 'color': 'red', 'priority': 2}
in the res
dictionary is replaced by {shape: square, color: green, priority: 3}
since 3>2 and so on.
So you can do this all in a single line in Python 2.7+:
{di['shape']:di for di in sorted(li1+li2, key=lambda d: d['priority'])}.values()