sort: implementing single thread