When clicking to sort on an ajax enabled Views table and on a column that has "Enable click sort: Sort Numerically" selected, I get the following error.

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /views/ajax
StatusText: OK
ResponseText:
( ! ) Fatal error: Function name must be a string in /home/ubuntu/workspace/sandbox/sites/all/modules/views_php/plugins/views/views_php_handler_field.inc on line 185
Call Stack
#TimeMemoryFunctionLocation
10.0002752424{main}(  )../index.php:0
20.509853025928menu_execute_active_handler(  )../index.php:21
30.510653163792call_user_func_array
(  )../menu.inc:503
40.510653164160views_ajax(  )../menu.inc:0
50.594264902000view->preview(  )../ajax.inc:71
60.644270358168views_plugin_display->preview(  )../view.inc:1155
70.644270358248view->render(  )../views_plugin_display.inc:2559
80.644270358328view->execute(  )../view.inc:1011
90.699174599344views_php_plugin_query->execute(  )../view.inc:991
100.699374635480views_plugin_query_default->execute(  )../views_php_plugin_query.inc:17
110.702174780296views_php_plugin_pager->post_execute(  )../views_plugin_query_default.inc:1373
120.710774792720views_php_handler_field->php_post_execute(  )../views_php_plugin_pager.inc:35
130.713874810960usort
(  )../views_php_handler_field.inc:162
140.713874811184views_php_handler_field->php_click_sort(  )../views_php_handler_field.inc:0

Comments

There are a few problems within the php_click_sort function:

1) The arguments, which are to be rows with data, do not contain fields, just contain the entity type definitions. See this dpm of the object I'm try to sort:

node_type (String, 9 characters ) report_he
nid (String, 4 characters ) 4126
node_title (String, 0 characters )
field_data_field_cus_titled_item_node_entity_type (String, 4 characters ) node
field_data_field_lot_number_node_entity_type (String, 4 characters ) node
field_data_field_ui_number_node_entity_type (String, 4 characters ) node
field_data_field_cus_consignor_node_entity_type (String, 4 characters ) node
field_data_field_serial_number_vin_node_entity_type (String, 4 characters ) node
field_data_field_odometer_node_entity_type (String, 4 characters ) node
field_data_field_hour_meter_ending_node_entity_type (String, 4 characters ) node
field_data_field_cus_emissions_node_entity_type (String, 4 characters ) node
field_data_field_description_node_entity_type (String, 4 characters ) node

2) The $function variable called on line 185 is an array, the second element of which is the click sort function name (in my case and yours "php_click_sort_numeric"). I can solve this issue by doing an ugly little hack to test the $function var to see if it's a string and if not populate $function with the value of the second element, but it's all moot because the incoming objects have no values. I believe this is related to this issue: http://drupal.org/node/1140896

I had the same problem, alpha sort works, but not numeric. Something wrong in the code for this.

I got numeric sort working just using a custom sort snippet though.

Here's how to do it:

Ensure the 'Value Code' field returns the correct value, eg in my case: return $row->tid; - this is what the sort works on.

Set the output in 'Output Code' eg

<?php
print $row->php;
?>
- if there is no value in your output, then it means your value code isn't correct.

Set the click sorting to 'Sort using custom PHP code' and do the sort like this: return $row1->php - $row2->php;

Click sorting should now work.

thanks for the working snippet, had the same issue.

Problem I am having is when ucing VALUE CODE field there is very limited data. Just title, and Node ID and for body I also get node ID. Not full node is loaded. So I have to either load a full node, or use in output code already loaded node, right?

Thank you modstore, works for me.

custom sort code that worked for me

<?php
$a
= $row1->php;
$b = $row2->php;
if (
$a == $b) {
  return
0;
}
return (
$a < $b) ? -1 : 1;
?>