Left: | ||
Right: |
OLD | NEW |
---|---|
1 import datetime, random | |
2 | 1 |
saroyanm
2016/02/01 16:24:54
Detail: No new line needed in the beginning of the
Sebastian Noack
2016/02/01 18:01:23
It seems the changes in here (except for the funct
juliandoucette
2016/02/02 16:44:45
Done.
juliandoucette
2016/02/02 16:44:46
Done.
| |
3 def datesort(value, basedate="1970-01-01", column=0): | 2 import random |
4 base = datetime.datetime.strptime(basedate, "%Y-%m-%d") | 3 from datetime import datetime |
4 | |
5 def randomsortbydate(value, basedate="1970-01-01", column=0): | |
6 base = datetime.strptime(basedate, "%Y-%m-%d") | |
5 def randdiff(entry): | 7 def randdiff(entry): |
6 date = datetime.datetime.strptime(entry[column], "%Y-%m-%d") | 8 date = datetime.strptime(entry[column], "%Y-%m-%d") |
7 diff = (date - base).days | 9 diff = (date - base).days |
8 return diff * 0.2 + random.randrange(diff) * 0.8 | 10 return diff * 0.2 + random.randrange(diff) * 0.8 |
9 return sorted(value, key=randdiff) | 11 return sorted(value, key=randdiff) |
OLD | NEW |