Types plugin provides a fields API, making it easy to display custom fields on your website’s front-end. The corresponding function call outputs the desired fields with a special formatting and supports different attributes for each field type.
The customer wants to sort results based on the comments count.
Solution:
Upon further review, I identified that the comment_count field in the wp_posts table can be used directly for sorting. I provided a code snippet to add to the theme's functions.php file to sort by the comment_count field: