OLD | NEW |
1 import datetime, random | 1 import datetime, random |
2 | 2 |
3 def datesort(value, basedate="1970-01-01", column=0): | 3 def teamsort(value, basedate="1970-01-01", column=0): |
4 base = datetime.datetime.strptime(basedate, "%Y-%m-%d") | 4 base = datetime.datetime.strptime(basedate, "%Y-%m-%d") |
5 def randdiff(entry): | 5 def randdiff(entry): |
6 date = datetime.datetime.strptime(entry[column], "%Y-%m-%d") | 6 date = datetime.datetime.strptime(entry[column], "%Y-%m-%d") |
7 diff = (date - base).days | 7 diff = (date - base).days |
8 return diff * 0.2 + random.randrange(diff) * 0.8 | 8 return diff * 0.2 + random.randrange(diff) * 0.8 |
9 return sorted(value, key=randdiff) | 9 return sorted(value, key=randdiff) |
OLD | NEW |