[prolog] add sort_list logic