There’s Enum.uniq_by/2 that you can use, as in Enum.uniq_by(list, fn(%{"source" => s}) -> s end)
The reason your filter doesn’t work is because you’re building the list as you enumerate the elements and you can’t mutate the variable sources. You can achieve what you want with a reduction, where you keep track of them as you exemplified:
For note, your sources ++ p["source"] expression is evaluated here but the result is thrown away since it’s not being returned.
And it looks like you aren’t just wanting a unique one based on the name, but also the one with the highest value in each set, thus I’d probably do either this: