I am trying to implement sorting over two fields lets say price, rating in order of asc, desc respectively. I see the results are not appropriate and after I print the statement I see the order is reversed i.e. I am geting statement ending with order by x23.x30 desc, x2.x7 which clearly is not correct. Here is some code..
//Filter param is a list of filter parameters.
val q3 = q2.sortBy(resultSort(_, filterParams.sortTerms.head, filterParams.sortDirections.head))
val direction = if(!filterParams.sortDirections.tail.isEmpty && filterParams.sortDirections.tail.head == "desc")
"desc"
else
"asc"
val q4 = if (!filterParams.sortTerms.tail.isEmpty){
q3.sortBy(resultSort(_, filterParams.sortTerms.tail.head, direction))
}
else q3
result sort is a method which will sort q2 query elements.
Is there something wrong here? if I do sort chaining the order should be as it is i.e. in this case Ideally order by should be x2.x7, x23.x32 desc
Thanks,
Pradeep