Skip to content

Instantly share code, notes, and snippets.

@smockle
Created April 3, 2013 19:58
Show Gist options
  • Save smockle/5304696 to your computer and use it in GitHub Desktop.
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#.
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