fix wrong sorting of affinity edges