views:

82

answers:

1

I want to sort by expression, then by some attribute ascending, then by another attribute ascending. Something like this: :order => "(a < some constant) desc, b asc, c asc". How to get it?

Extended sorting refuses to work because of <. Expr fails because of commas.

I have managed to produce sorting equivalent to :order => "(a < some constant) desc, b desc" with :order => "(a < some constant)", :sort_mode => :expr, :sort_by => :b, but I can't add another attribute (c) to that sorting nor change sorting mode for b to asc.

A: 

SetSelect function allows for creating arbitrary sorts. I am not sure if it is available in thinking-sphinx, so modification of this gem may be necessary.

skalee