sunspot/sunspot — pull request #292 by dz (2012-09-27 05:26:26+00:00)
Title: When performing an order_by call, allow sorting on Solr fields with invalid Ruby constant characters

I have some dynamic solr fields in the form of `default_release.release_date` and `default_release.version`, and I'd to be able to order on the the date or version.

Unfortunately, as part of the `Sunspot::Query::Sort.special` method, a naive `const_defined?` call is made, which triggers a `NameError: wrong constant name` when encountering a passed in field that contains invalid Ruby constant characters.

This request makes an additional check before calling `const_defined?` to ensure that the field is a valid constant name to begin with, before checking to see if it matches a constant defined on `Sort`.