Skip to content

Instantly share code, notes, and snippets.

@xiaokangwang
Created September 21, 2017 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xiaokangwang/272455421bd3004a951f53fce01b9f91 to your computer and use it in GitHub Desktop.
Save xiaokangwang/272455421bd3004a951f53fce01b9f91 to your computer and use it in GitHub Desktop.
Sort Cite with Year It was written
BEGIN{
Count=0
}
{
input[Count]=$0
Count++;
}
function SortByYear(i1, v1, i2, v2, l, r) {
Year1=match(v1, /20([0-9]){2}/, year)
v1=year[0]
Year2=match(v2, /20([0-9]){2}/, year)
v2=year[0]
return int(v1)-int(v2)
}
END{
asort(input, out, "SortByYear")
for (i in out) {
print out[i]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment