backport sortByName() to 0.9.X

Backporting PR #522 to the 0.9.x branch. This seems to have been in at one point; because the original patch for master (a different PR) was upported from 0.9.x. While testing 10.0-alpha with Grafana; the sortByName() Function did just that..function. When reverting back to the latest 0.9.x source; the function caused all of my grafana panels to go blank. Panel was calling for a function that's not in 0.9.x.

see (https://github.com/grafana/grafana/issues/690) for more details.


Seems like this should probably be collapsed to a lambda instead of a full first class function declaration since there isn't any obvious case where you'd be reusing that inner function.