KoolGrid support column sorting. To enable this feature, you set $AllowSorting property to true. Setting this property in KoolGrid's instance or in GridTableView's instance will enable sorting feautre of all sortable column.
<?php
$KoolControlsFolder = "../../../../KoolControls";//Relative path to "KoolPHPSuite/KoolControls" folder
require $KoolControlsFolder."/KoolAjax/koolajax.php";
$koolajax->scriptFolder = $KoolControlsFolder."/KoolAjax";
require $KoolControlsFolder."/KoolGrid/koolgrid.php";
require $KoolControlsFolder."/KoolGrid/ext/datasources/MySQLiDataSource.php";
$ds = new MySQLiDataSource($db_con);//This $db_con link has been created inside KoolPHPSuite/Resources/runexample.php
$ds->SelectCommand = "select customerNumber,customerName,phone,city from customers";
$grid = new KoolGrid("grid");
$grid->scriptFolder = $KoolControlsFolder."/KoolGrid";
$grid->styleFolder="sunset";
$grid->DataSource = $ds;
$grid->Width = "655px";
$grid->RowAlternative = true;
$grid->AjaxEnabled = true;
$grid->AutoGenerateColumns = true;
$grid->AllowSorting = true;//Enable sorting for all rows;
$grid->MasterTable->Pager = new GridPrevNextAndNumericPager();
$grid->Process();
?>
<form id="form1" method="post">
<?php echo $koolajax->Render();?>
<div style="padding-bottom:5px;">
Click column header to sort:
</div>
<?php echo $grid->Render();?>
<div style="margin-top:10px;"><i>* <u>Note</u>:</i>Generate your own grid with <a style="color:#B8305E;" target="_blank" href="http://codegen.koolphp.net/grid/">Code Generator</a></div>
</form>