Tsort is a table column sort for non-sql tables. It allows you to sort a table by any column heading, where the table data is not directly pulled from a database, but is simply in an array of rows. It does this by providing a new function, tsort_nonsql_sort(), which will sort your rows for you according to the column which has been clicked.
Example Usage
The following example shows a full example of usage. The function which is provided by this module is the following one:
tsort_nonsql_sort($rows, $sort, $column);
All the rest of the sample code below is standard Drupal coding for a table which
has rows and can be themed.
<?php
/**
* Create a sorted version of the players table
* The players table has the following columns:
* - uid, name, rating, played, won, lost, drawn, rating, rating change, current
*/
function gamer_players() {
$sql = "SELECT uid FROM {users} ORDER BY name";
// Converted to the D7 database API syntax.
$result = db_query($sql);
foreach ($result as $record) {
if ($record->uid <> 0) {
$player_stats = gamer_load_user_stats($record->uid);
$rows[] = array(
'uid' => $record->uid,
'name' => "" . $player_stats['name'] . "",
'rating' => $player_stats['rating'],