Javascript array sort not working on iOS


I have this sample code (that renders perfectly on Android) sorting an array. On iOS, the results are not correct (see pictures attached):

var items = [{fid:"1498305528359"},{fid:"1498907259659"},{fid:"1499104313002"}]

items.sort(function(a,b) {return (a.fid > b.fid) ? 1 : ((b.fid > a.fid) ? -1 : 0);} );
alert(items[0].fid+", "+items[1].fid+", "+items[2].fid)


Hey, I see you are comparing strings lexicographically, perhaps you want to compare their numeric values?


I’ve tried both ways with the same results.