The fix for issue 9750 introduced a regression by sorting the row objects
returned by fetchall. But if a row_factory such as sqlite3.Row is used, the
rows may not be sortable (in Python3), which leads to an exception. The
sorting is still a nice idea, so the patch moves the sort into the sql.
Fix and test by Peter Otten.