this can be substantially simplified, to take advantage of javascript's type coercion

return Number(new Date(a[opts.by]) > new Date(b[opts.by]))

since 
Number(false) === 0 and Number(true) === 1