Sorting Slick query results in a for expression

3.3k Views Asked by At

The following function works fine, but I would like it to sort the results first by parent_id, and then by order.

def getTree = for {
  (a, c) <- Activities leftJoin Clients on (_.id === _.id_a)
} yield (a.id, a.label, a.parent_id, a.order, c.id.?, a=c.name)

How do I do that using Slick?

2

There are 2 best solutions below

3
On BEST ANSWER

Like with ordinary collection ?

getTree.sortBy(r => r._3 ~ r._4)
0
On

With Slick 2.1, I found this to work:

myQuery.sortBy(r => (r._3, r._4))

(verified by calling selectStatement on my query)