fix #1587 (sorting sometimes returns 0 answers)

v1.21.2.2

cherry picked commit from jygaulier to fix #1587