Implement sort and format