Fixed sqlite order by bug