Sort values before writing them out