resolved fdo#77018 keep external references intact during sort

Needs e463de2a56453a0d2cb0b5b58e96f7639f37cdd1 fix for fdo#79441 to
work.

Change-Id: Ide1cbeb4b25b17b5102977ccbdf8e6dbfcadfc60
(cherry picked from commit db0a4c2575ffba1c170d74882b0f5a6229ec072f)
Reviewed-on: https://gerrit.libreoffice.org/10246
Reviewed-by: David Tardon <dtardon@redhat.com>
Reviewed-by: Kohei Yoshida <libreoffice@kohei.us>
Reviewed-by: Muthu Subramanian K <muthusuba@gmail.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>