almost fibonacci- skip the first 2 steps e.g. 1, 2, 3, 5, 8, ... instead of 0, 1, 1, 2, 3, ... otherwise ordering of the elements at '1' is undefined... ;)
(order_col)
| 26 | |
| 27 | |
| 28 | def fibonacci_numbering(order_col): |
| 29 | """ |
| 30 | almost fibonacci- skip the first 2 steps |
| 31 | e.g. 1, 2, 3, 5, 8, ... instead of 0, 1, 1, 2, 3, ... |
| 32 | otherwise ordering of the elements at '1' is undefined... ;) |
| 33 | """ |
| 34 | |
| 35 | def f(index, collection): |
| 36 | if index == 0: |
| 37 | return 1 |
| 38 | elif index == 1: |
| 39 | return 2 |
| 40 | else: |
| 41 | return getattr(collection[index - 1], order_col) + getattr( |
| 42 | collection[index - 2], order_col |
| 43 | ) |
| 44 | |
| 45 | return f |
| 46 | |
| 47 | |
| 48 | def alpha_ordering(index, collection): |