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
due_date ASC sort: pgsql fix

Fix #16259: adding order by expression to select list to avoid error.