Tidy up filter.order parsing

/to @ritch 
None of this code is specific to postgres is it?