the data sorting not proper , looks like
0 1 10 11 2 20 21 3
here order code
$select->order('post_meta.meta_value int desc');
note meta_value
field longtext , not int , cannot change fix problem need fix.
ok, according comment question how sort in php can think of this:
<?php $stringarray = [0, '1', 10, '11 2', '20 21', 3]; usort($stringarray, function($a, $b) { $a = (int)trim(preg_replace('/\s+/', '', $a)); $b = (int)trim(preg_replace('/\s+/', '', $b)); if ($a === $b) { return 0; } return ($a > $b) ? -1 : 1; }); var_dump($stringarray); ?>
Comments
Post a Comment