Index: poll/views_handler_sort_poll_votes.inc
===================================================================
--- poll/views_handler_sort_poll_votes.inc	(revision 0)
+++ poll/views_handler_sort_poll_votes.inc	(revision 7146)
@@ -0,0 +1,16 @@
+<?php
+
+class views_handler_sort_poll_votes extends views_handler_sort_formula {
+  /**
+   * Constructor to take the formula this sorts on.
+   */
+  function construct() {
+    $this->definition['formula'] = 'COUNT(poll_votes.uid)';
+    parent::construct();
+  }
+  
+  function query() {
+    $this->query->add_groupby("node.nid");
+    parent::query();
+  }
+}
Index: poll/views_handler_field_poll_votes.inc
===================================================================
--- poll/views_handler_field_poll_votes.inc	(revision 0)
+++ poll/views_handler_field_poll_votes.inc	(revision 7587)
@@ -0,0 +1,19 @@
+<?php
+class views_handler_field_poll_votes extends views_handler_field {
+  function query() {
+    $this->ensure_my_table();
+    // Add the field.
+    $this->field_alias = $this->query->add_field(NULL, "COUNT($this->table_alias.nid)", $this->field);
+    $this->query->add_groupby("node.nid");
+    $this->add_additional_fields();
+  }
+  
+  /**
+   * Called to determine what to tell the clicksorter.
+   */
+  function click_sort($order) {
+    $this->query->add_orderby(NULL, "COUNT($this->table_alias.nid)", $order, $this->field_alias);
+    $this->query->add_groupby($this->view->base_table . "." . $this->view->base_field);
+
+  }
+}
Index: modules/poll.views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/modules/poll.views.inc,v
retrieving revision 1.4
diff -u -p -r1.4 poll.views.inc
--- modules/poll.views.inc	3 Dec 2008 19:10:21 -0000	1.4
+++ modules/poll.views.inc	30 Jan 2009 17:40:52 -0000
@@ -13,6 +13,25 @@
  */
 
 /**
+ * Implementation of hook_views_handlers().
+ */
+function poll_views_handlers() {
+  return array(
+    'info' => array(
+      'path' => drupal_get_path('module', 'views') .'/modules/poll',
+    ),
+    'handlers' => array(
+      'views_handler_sort_poll_votes' => array(
+        'parent' => 'views_handler_sort_formula',
+      ),
+      'views_handler_field_poll_votes' => array(
+        'parent' => 'views_handler_field',
+      ),
+    ),
+  );
+}
+
+/**
  * Implementation of hook_views_data()
  */
 function poll_views_data() {
@@ -27,6 +46,14 @@ function poll_views_data() {
     ),
   );
 
+  $data['poll_votes']['table']['group'] = t('Poll');  
+  $data['poll_votes']['table']['join'] = array(
+    'node' => array(
+      'left_field' => 'nid',
+      'field' => 'nid',
+    )
+  );
+
   // ----------------------------------------------------------------
   // Fields
 
@@ -47,6 +74,18 @@ function poll_views_data() {
       'handler' => 'views_handler_sort',
     ),
   );
+  
+  // meta field to count the number of votes
+  $data['poll_votes']['votes'] = array(
+    'title' => t('Number of votes'),
+    'help' => t('Count of the number of votes for this poll'),
+    'sort' => array(
+      'handler' => 'views_handler_sort_poll_votes',
+    ),
+    'field' => array(
+      'handler' => 'views_handler_field_poll_votes',
+    ),
+  );
 
   return $data;
 }
