In the documentation for the slice_min() and slice_max() functions it says that the order_by argument can be a variable or functio
slice_min()
slice_max()
order_by