Created
April 3, 2013 19:58
-
-
Save smockle/5304696 to your computer and use it in GitHub Desktop.
MonthComparer matches month names to month numbers for comparison. It's written in C#.
This file contains 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
public class MonthComparer : IComparer<string> { | |
public int Compare(string a, string b) { | |
var c = DateTime.ParseExact(a, "MMMM", CultureInfo.CurrentCulture).Month; | |
var d = DateTime.ParseExact(b, "MMMM", CultureInfo.CurrentCulture).Month; | |
return c - d; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment