Function from WordPress VoteItUp function
These are my suggestions


Don't use mysql functions to connect and query Wordpress posts. 
You can replace the first SQL statement with this WP_Query. 

$query = new WP_Query('post_type=post&amp;post_status=publish&amp;orderby=date&amp;order=DESC');
$pageposts = $query-&gt;get_posts();  


This way the code is somewhat protected from future Wordpress database changes.
The second select statement is a bit unnecessary as each $post in the $pagepost already contains the post id. 
Only thing missing is the limit, but we'll add that to the WP_Query by adding

$query = new WP_Query('post_type=post&amp;post_status=publish&amp;orderby=date&amp;posts_per_page='.$upperlimit);

Refactor and remove unused/unnecessary code

global $wpdb, $voteiu_databasetable - are not needed anymore
$upperlimit - assignment can be done on one line
$lowerlimit - not used anymore as it's enough with the $upperlimit 
$output = $pageposts; - assigmentent before return is unnecessary


So the complete ShowPostByVotes in votingfunctions.php would look something like this now:

function ShowPostByVotes() {

    $upperlimit = is_numeric(get_option('voteiu_limit')) ? get_option('voteiu_limit') : 100 ;

    $query = new WP_Query('post_type=post&amp;post_status=publish&amp;orderby=date&amp;posts_per_page='.$upperlimit);
    $pageposts = $query-&gt;get_posts();        
    $votesarray = array();
    foreach ($pageposts as $post) {
        $vote_array = GetVotes($post-&gt;ID, "array");
        array_push($votesarray, array(GetVotes($post-&gt;ID)));
    }

    array_multisort($votesarray, SORT_DESC, $pageposts);
    return $pageposts;

}


And you can use it in your index.php by using this code

 &lt;?php $pageposts = ShowPostByVotes();  ?&gt;
 &lt;?php if ($pageposts): ?&gt;
  &lt;?php global $post; ?&gt;
  &lt;?php foreach ($pageposts as $post): ?&gt;
    &lt;?php setup_postdata($post); ?&gt;

    &lt;div class="post" id="post-&lt;?php the_ID(); ?&gt;"&gt;
      &lt;h2&gt;&lt;a href="&lt;?php the_permalink() ?&gt;" rel="bookmark" title="Permanent Link to &lt;?php the_title(); ?&gt;"&gt;
      &lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt;
      &lt;small&gt;&lt;?php the_time('F jS, Y') ?&gt; &lt;!-- by &lt;?php the_author() ?&gt; --&gt;&lt;/small&gt;
      &lt;div class="entry"&gt;
         &lt;?php the_content('Read the rest of this entry »'); ?&gt;
      &lt;/div&gt;

      &lt;p class="postmetadata"&gt;Posted in &lt;?php the_category(', ') ?&gt; | &lt;?php edit_post_link('Edit', '', ' | '); ?&gt;  
      &lt;?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?&gt;&lt;/p&gt;
    &lt;/div&gt;
  &lt;?php endforeach; ?&gt;

  &lt;?php else : ?&gt;
    &lt;h2 class="center"&gt;Not Found&lt;/h2&gt;
    &lt;p class="center"&gt;Sorry, but you are looking for something that isn't here.&lt;/p&gt;
    &lt;?php include (TEMPLATEPATH . "/searchform.php"); ?&gt;
 &lt;?php endif; ?&gt;