Ash FrameworkAF
Ash Framework8mo ago
7 replies
ajst7les

Adding a custom sort

I have a field which is an atom. I want to sort it with a custom sort order:

I am imagining something like this but I can;t find the exact syntax:
prepare fn query, _ ->
query
|> Ash.Query.sort([
Ash.Sort.expr_sort(
case :deliver_before do
:"10am" -> 1
:"2pm" -> 2
:"6pm" -> 3
:"10pm" -> 4
:no_preference -> 5
end,
:integer
)
])
end

is this possible in ash?
Was this page helpful?