Remove useless code
When sorting by due_date, display undefined values last

Markus' original patch was modified to simplify the code and reduce
duplication, fix a couple typos in comment text and reword the
commit message.

Fixes #16259
Remove DISTINCT clause from filter_get_bug_rows query

Fixes #16259 PostgreSQL error when filtering by due_date ASC