wrap Array.sort and compare NaN correctly