Thomas, here's the sort function by DataStore:
usort($this->rows,
function ($a, $b) use ($sorts) {
$cmp = 0;
foreach ($sorts as $sort => $direction) {
if (is_string($direction)) {
$cmp = is_numeric($a[$sort]) && is_numeric($b[$sort]) ?
$a[$sort] - $b[$sort] : strcmp($a[$sort], $b[$sort]);
$cmp = $direction === 'asc' ? $cmp : - $cmp;
} else if (is_callable($direction)) {
$cmp = $direction($a[$sort], $b[$sort]);
}
if ($cmp !== 0) {
break;
}
}
return $cmp;
}
);
If your values are all numbers or numeric strings (int, float, double, etc) a simple arithmetic comparison is used. Otherwise, string comparison is used. You also have another option to use an anonymous function for comparison like this:
$myDS->sort(array("column1" => function($a, $b) {
//compare $a and $b here and return result.
}));
In case there's still confusion please post one of your sample data here (or via email) together with your sorting code. We will test it directly for you. Cheers, Sebastian.