Created
June 16, 2012 09:28
-
-
Save Loupax/2940690 to your computer and use it in GitHub Desktop.
Group sorting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function group_sort($array, $order) | |
| { | |
| $new = array(); | |
| foreach ($array as $row){ | |
| foreach ($order as $ord){ | |
| $new[$ord][] = $row[$ord]; | |
| } | |
| } | |
| $str = ''; | |
| for ($i=0; $i<count($order); $i++) | |
| { | |
| $str .= '$new[$order['.$i.']],'; | |
| } | |
| //Remove the last coma | |
| $str = substr_replace($str ,"",-1); | |
| eval('array_multisort('.$str.');'); | |
| return $new; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment