using priority to sort neurons in the same layer