added sort and write-time logging