How to sort a varchar numerically using the api
I see if we try to modify the sort col with any sql defined functions, it gets returned with the Error Message. For Eg - ['sort' =&gt; 'CAST(value AS decimal) DESC'] returns


  Unknown field specified for sort. Cannot order by 'CAST(value AS decimal) DESC'.


Maybe, there should be some modification in CRM_Utils_Rule::mysqlOrderBy() to either handle such cases.

Or we can simply use get instead of getsingle and then order the returned result values using array functions.