Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: filters/teamsort.py

Issue 29334171: Issue 3410 - Added date sort / format for press releases (Closed)
Left Patch Set: Fixed rename, typos, and function names Created Jan. 25, 2016, 4:18 p.m.
Right Patch Set: Fixed datetime call Created Feb. 9, 2016, 4 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « filters/humanize_date.py ('k') | includes/press/releases.tmpl » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 import random
2 from datetime import datetime
3
4 def teamsort(value, basedate="1970-01-01", column=0):
5 base = datetime.strptime(basedate, "%Y-%m-%d")
6 def randdiff(entry):
7 date = datetime.strptime(entry[column], "%Y-%m-%d")
8 diff = (date - base).days
9 return diff * 0.2 + random.randrange(diff) * 0.8
10 return sorted(value, key=randdiff)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld