basta che quando fai il SELECT aggiungi alla fine ORDER BY nomecampo e i risulatati ti vengono dati ordinati in base a l campo scelto...