[ticket/11691] Add order by to the query

PHPBB3-11691
[ticket/11691] Fix typo in comment

PHPBB3-11691
[ticket/11691] Move purge code into new function

PHPBB3-11691