Implemented function `sort`