better JSArray.sort() exception handling