I don't understand why you need to ```ORDER BY unnest``` and then sort again programmatically. If it is really needed, could you add a proper comment?