Technically you can re-write your query, replace SELECT DISTINCT ON with an aggregate function like MAX and GROUP BY. Then you'll be able to group and sort at any order you like.