I want to let user click the table header to sort the table, but can just set the ascending order, can not set the descending order in the same table header. following is the function I used,
function sortBy(sKey)
{
document.sortResultsForm.sSortBy.value=sKey;
document.sortResultsForm.submit();
}
function sortDistrictNamedescend($a, $b)
{
if ($a->DistrictName == $b->DistrictName)
{
return 0;
}
return ($a->DistrictName < $b->DistrictName) ? 1 : -1;
}
function sortDistrictNameascend($a, $b)
{
if ($a->DistrictName == $b->DistrictName)
{
return 0;
}
return ($a->DistrictName < $b->DistrictName) ? -1 : 1;
}
if($sSortBy=="District")
{
usort($tempArr, 'sortDistrictNameascend');
}