move the sort to write command util