Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Functional PHP 5.3 - What are Anonymous Functions and Closures?.
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;"); }
There are no comments on this comment yet.
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:
Not my proudest moment, to be sure.