|
|
|
|
|
by phicou
6147 days ago
|
|
This should be a big help in writing clean server-side sorts by an arbitrary column in tabular data. Previously we've had to do some rather ugly things with "create_function" and lots of escaping in order to make arbitrary sort comparator functions. An example of the old style: private function makeCompare($field, $desc) {
return create_function('$a,$b', "
\$r = strcasecmp(\$a['$field'], \$b['$field']);
return " . ($desc ? '-1' : '1') . " * \$r;");
}
Not my proudest moment, to be sure. |
|