I would like to sort my links using an algorithm, all the information needed can be derived from values in my Links table. How can I return items sorted by the item’s calculated Score?
Schema https://gist.github.com/1326044
Index Action https://gist.github.com/1326045
Time Calculation https://gist.github.com/1326050
Algorithm
# Score = (P-1) / (T+2)^G
# P = points of an item (and -1 is to negate submitters vote)
# T = time since submission (in hours)
# G = Gravity, defaults to 1.8
I’d do as follows:
First, in your model:
In your controller: