Forcing numbers to sort properly
Let's say you have a drop-down field on your form with choices ranging from 1 to 10 or greater.
And you try to sort your View by this field:
GravityView can't sort text-based fields as if they were numbers. So your View will probably appear like this, with the Order column not correctly sorted.
There's a way to force GravityView to interpret those fields as if they were numbers by using a special filter:
add_filter( 'gravityview_search_criteria', 'gravityview_force_numeric_sort', 10, 3 );
function gravityview_force_numeric_sort( $criteria, $form_ids = array(), $context_view_id = 0 ) {
$criteria['sorting']['is_numeric'] = true;
return $criteria;
}
Click here to see here where to add this code snippet.
This will force the View to sort these choices as if they were numbers:
This filter doesn't work for sorting a secondary field, unfortunately.