javascript - Sort returning different results in different browsers -
function sort(type) { $("#parentdiv").empty(); $.getjson("raw_data.json", ({ search }) => { search.sort((a, b) => a[type] > b[type]); console.log(`sorted by: ${type}`); ...code
different results shown in different browsers, correct 1 showing in firefox devoloper edition , wrong results shown in chrome browser.
the sort function should return number,
a number less 0 move element a lower index b
a number greater 0 move element b lower index a
if number 0 leave elements @ same place.
more sort function here: https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/array/sort