sort list accepted using cpp