La discussione che hai postato tu su http://stackoverflow.com è chiarissima, come vedo hai una funziona che ti richiama l'estrazione mysql_select_db() bene ti crei tante varianti di selezione nel tuo caso per nome o cognome e fai il select per cognome o nome, ecc

guarda qui te lo spiega ancora meglio:

Codice PHP:
<?php
$orderBy 
= array('type''description''recorded_date''added_date');

$order 'type';
if (isset(
$_GET['orderBy']) && in_array($_GET['orderBy'], $orderBy)) {
    
$order $_GET['orderBy'];
}

$query 'SELECT * FROM aTable ORDER BY '.$order;

// retrieve and show the data :)
?>