How to use ‘WP_Query’ or ‘query_posts’ to display content in a descending order

You can store the counts as key and link a value and sort them before display like this :

$sort_tab = array();
while (have_posts()) : the_post();

if ( has_post_thumbnail() ) {
the_post_thumbnail( array(40,40) );
}

$url = get_the_permalink();
$json = file_get_contents( 'https://graph.facebook.com/fql?q=SELECT%20like_count,%20total_count,%20share_count,%20click_count,%20comment_count%20FROM%20link_stat%20WHERE%20url%20=%20%27' . $url . '%27' );
$json_data = json_decode($json, false);
$sort_tab[$json_data->data[0]->total_count] = $url;

endwhile;
sort($sort_tab);

foreach($sort_tab as $count=>$link)
{
    echo $link.' has '.$count.' votes';
}

tech