adding sort function