added sort parameters reading from input and wirting then to output