Resolves fdo#81084 fdo#81696 fdo#80874 fdo#81010 : sort causes crash

Change-Id: I8fb9ec26bc549c264bfbf30177d720b20677b319
Reviewed-on: https://gerrit.libreoffice.org/11102
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
(cherry picked from commit c25ac84688b596b9990d382d550f0514161b78c2)
Reviewed-on: https://gerrit.libreoffice.org/11137
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>