Sorting neighbors by compatibility