Created
September 21, 2017 13:16
-
-
Save xiaokangwang/272455421bd3004a951f53fce01b9f91 to your computer and use it in GitHub Desktop.
Sort Cite with Year It was written
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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