Released v0.2.0 version in which added sorting by joint query.
Let’s assume you have User and Post schemas, Repo module. And users has many posts. If you need sort users by post’s titles than your code will look like:
alias EctoJuno.Query.Sorting
def sort_users_by_posts do
params = %{"sort_by" => "title", "sort_direction" => "desc"}
User
|> join(:left, [u], p in assoc(u, :posts), as: :posts)
|> Sorting.sort_query(User, params, :posts)
|> Repo.all()
end
In the next version there’ll be sorting templates: you can define which schema and or binding will be used based on sorting field you passing by


















