We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File /lib/db/jig/mapper.php My variant is
protected function sort($data,$cond) { if($cond == '_random') { $keys = array_keys($data); shuffle($keys); $random = array(); foreach ($keys as $key) $random[$key] = $data[$key]; return $random; } $cols=\Base::instance()->split($cond); uasort( $data, function($val1,$val2) use($cols) { foreach ($cols as $col) { $parts=explode(' ',$col,2); $order=empty($parts[1])? SORT_ASC: constant($parts[1]); $col=$parts[0]; if (!array_key_exists($col,$val1)) $val1[$col]=NULL; if (!array_key_exists($col,$val2)) $val2[$col]=NULL; list($v1,$v2)=[$val1[$col],$val2[$col]]; if ($out=strnatcmp($v1,$v2)* (($order==SORT_ASC)*2-1)) return $out; } return 0; } ); return $data; }
do it like this, or please add your own better way random sorting
The text was updated successfully, but these errors were encountered:
I wouldn't really consider shuffling to be a way to sort things. If I needed a shuffle method on my mappers, I'd probably just add one.
Sorry, something went wrong.
I'd want to keep with the f3 mantra and keep things light. That being said, if I needed to randomize the order I would do that in my app not the core.
No branches or pull requests
File /lib/db/jig/mapper.php
My variant is
do it like this, or please add your own better way random sorting
The text was updated successfully, but these errors were encountered: