is there a way to overwrite the views Sort criteria? i have overwritten a field's output, and want to use it as the Sort criteria. so i must overwrite the Sort criteria?  is there a way to overwrite the views module Sort criteria?

the sort criteria is:

table votingapi_vote, the field content_id,which is $node->nid, the vaule=1. i want to to sort it by the number counts of the vaule. desc. HOW TO do it?

if i want to alter the  sort criteria in the template.php, is there a way to get it?
Sure, just use hook_views_query_alter().
You can intercept the view's query object and make any changes you need to it, including (but not limited to) adding/removing sort criteria.

Better WHERE's for your Drupal forums with hook_views_query_alter and Using hook_views_query_alter to change your views sort order give some examples of how to alter a view query.