function compareRows($row1, $row2) { global $sortBy, $sortDesc; $sortStr = Row::isFieldStr($sortBy); $f1 = $row1->getField($sortBy); $f2 = $row2->getField($sortBy); if (!$sortStr) { $f1 = $f1 - 0; $f2 = $f2 - 0; } $r = 0; if ($sortStr) { $r = strcmp($f1, $f2); } else { $r = $f1 == $f2 ? 0 : $f1 > $f2 ? 1 : -1; } if ($sortDesc) { $r = -$r; } return $r; }