fdo#78079: Re-work sort by column to get it to do the right thing.

Also fixed reference update problem.

(cherry picked from commit 3c4fb52d8fc89fe43983991ed2339295b2e0ef8c)

Conflicts:
	sc/inc/column.hxx

Change-Id: I06e6115ef969a011fdd5c92d5eb1927fb7ae789b
Reviewed-on: https://gerrit.libreoffice.org/9220
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>