Improve min/max to be order-independent when handling null/undefined/NaN

closes #233