Fixed reference column sorting

Related cards were being taken into account in the wrong place