Search code examples
scalascalaqueryslick

Sorting Slick query results in a for expression


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?


Solution

  • Like with ordinary collection ?

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