Back-port Kohei's comprehensive sorting unit tests from master.

As of master commit fab88063281761dbdac7ea550072660fe0f8c863.

Change-Id: I45ee0021c727281ba5590ceead6d8c5848e25169
Reviewed-on: https://gerrit.libreoffice.org/11903
Reviewed-by: Muthu Subramanian K <muthusuba@gmail.com>
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>