I'd like to know why lodash doesn't sort array of dates in string format as compared with plain javascript sort(). Is it expected behavior or a bug?
var array = ["2014-11-11", "2014-11-12", null, "2014-11-01", null, null, "2014-11-05"];
_.sortBy(array);
// ["2014-11-11", "2014-11-12", null, "2014-11-01", null, null, "2014-11-05"]
_.sortBy(array, function(value) {return new Date(value);});
// [null, null, null, "2014-11-01", "2014-11-05", "2014-11-11", "2014-11-12"]
array.sort();
// ["2014-11-01", "2014-11-05", "2014-11-11", "2014-11-12", null, null, null]
Version used: Lo-Dash v2.4.1 – Modern build.