You can check out the Help page `Using When Ordere...
# general
e
You can check out the Help page
Using When Ordered By Field for Search Results
for some examples of how to do this sort of thing