add sort method and tests for merge method