Sort results by a computed value

There is no native FQL Sort function, though there is a recent feature request for one already: Native Sort Function

Are you suggesting adding to that a Lambda argument to determine the order? That would be handy! Here might be one example. What do you think?

Sort(
  items,
  Lambda(["first", "second"], Subtract(Var("first"), Var("second")))
)

also…

Index bindings can sort by computed value

If you need to sort values before pagination, you can include index bindings in the values and your index will sort on them.

Avoid computing with FQL if possible

FQL is not a great choice for general-purpose computing. It is very powerful when you need to operate close to the data, and can be critical if that compute needs to be part of the transaction.

However, if you find yourself performing a lot of compute after your data has been paginated, you might consider if it is truly necessary. There are most certainly cases where it will be. For other cases, it might be best to return a page as is and transform client-side.

The case where it is likely not necessary is performing a transformation that does not affect the underlying Set.