How to Sort a bunch of Things by Date
In a typical Space, you often want to list a collection of Things in Date order -- specifically, you usually want to list them with the most recently changed ones on top, so that folks can see what's new.
The key methods for doing this are _sort, _desc and _modTime:
- _sort sorts a bunch of values that you pass in to it, based on the property or method you tell it;
- _desc ("descending") says to reverse the sort order;
- _modTime ("modification time") receives a Thing, and produces the DateTime when that Thing was last changed.
You want to give _sort a collection of Things, and tell it to sort on their _modTime. (Most often in _desc order.) For example, to list all of the Recipes in this Space, in time order with the most recently-changed on top, you would say:
[[Recipe._instances -> _sort(_desc(_modTime)) -> ""[[_modTime]]: ____""]]
and you would see this: