Been capable of sorting results (ASC, DESC) by total wordcount or nº of comment would be great. I hardcoded a sorting method for total (DESC) in wordcount_show_count() function this way:
foreach ($row as $k=>$v) {
$row[$k]['avg_post'] = ($row[$k]['posts']) ? number_format($row[$k]['num_words_post']/$row[$k]['posts'], 1) : 0;
$row[$k]['avg_comment'] = ($row[$k]['comments']) ? number_format($row[$k]['num_words_comment']/$row[$k]['comments'],1) : 0;
$row[$k]['total'] = $row[$k]['num_words_post'] + $row[$k]['num_words_comment'];
}
// NEW CODE
function cmp($a, $b) {
if ($a["total"] == $b["total"]) {
return 0;
} else {
return ($a["total"] > $b["total"]) ? -1 : 1;
}
}
usort($row, "cmp");
// END OF NEW CODE
$header = array(
array ('data' => 'id'),
...
Not going to win a PHP coding contest, but works for me
Comments
Comment #1
crookednumber commentedThanks for the ideas, Metafriki.
This has (essentially) been accomplished in 6-1.1, using the tablesorter jquery plugin.
http://drupal.org/node/583868