0

我正在使用 Brave(然后我检查了 Chrome 81)并且无法获得正确的排序:根本没有排序。然后我尝试使用 Firefox 74,结果是正确的!?!?!

我不敢相信这是一个 Chrome 错误,但还有什么?我只是再次交叉检查。

这是我的一段代码(一个巨大的 geojson 文件的一小部分),在两个浏览器的同一页面上进行了测试: https ://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array /种类

const ff = [
{"properties":{"libel_s":"Châtenois-Dolaincourt","slug_s":"Chatenois-Dolaincourt","uic_s":87144360,"pk":"70+475","rang":1,"idreseau":30000003663,"frevoy":"ON","num_s":"030000","dept":"88","nom_s":"Châtenois"},"type":"Feature","geometry":{"type":"Point","coordinates":[5.838898157124752,48.3016159832871]}},
{"properties":{"libel_s":"Dompaire","slug_s":"Dompaire","uic_s":87144774,"pk":"107+095","frevoy":"NN","num_s":"030000","dept":"88","nom_s":"Dompaire"},"type":"Feature","geometry":{"type":"Point","coordinates":[6.227413,48.21918]}},
{"properties":{"libel_s":"Aulnois-Bulgneville","slug_s":"Aulnois-Bulgneville","uic_s":87144378,"pk":"64+679","rang":1,"idreseau":30000008513,"frevoy":"NN","num_s":"030000","dept":"88","nom_s":"Aulnois"},"type":"Feature","geometry":{"type":"Point","coordinates":[5.79276278179999,48.26129746043176]}},
{"properties":{"libel_s":"Neufchâteau","slug_s":"Neufchateau","uic_s":87141291,"pk":"48+782","rang":1,"idreseau":30000005759,"frevoy":"OO","num_s":"030000"},"type":"Feature","geometry":{"type":"Point","coordinates":[5.69156366143611,48.35944961407943]}},
{"properties":{"libel_s":"Mirecourt","slug_s":"Mirecourt","uic_s":87144212,"pk":"94+156","rang":1,"idreseau":30000005527,"frevoy":"NO","num_s":"030000","dept":"88","nom_s":"Mirecourt"},"type":"Feature","geometry":{"type":"Point","coordinates":[6.128989839330904,48.29961812642761]}},
{"properties":{"libel_s":"Épinal","slug_s":"Epinal","uic_s":87144006,"pk":"126+801","rang":1,"idreseau":30000004058,"frevoy":"OO","num_s":"030000","dept":"88","nom_s":"Épinal"},"type":"Feature","geometry":{"type":"Point","coordinates":[6.441651,48.177831]}},
{"properties":{"libel_s":"Velotte-et-Tatignécourt","slug_s":"Velotte-et-Tatignecourt","uic_s":87146043,"pk":"100+530","frevoy":"NN","num_s":"030000","dept":"88","nom_s":"Velotte-et-Tatignécourt"},"type":"Feature","geometry":{"type":"Point","coordinates":[6.169486,48.259674]}},
{"properties":{"libel_s":"Racécourt","slug_s":"Racecourt","uic_s":87146035,"pk":"102+222","frevoy":"NN","num_s":"030000","dept":"88","nom_s":"Racécourt","info":"exemple de Halte"},"type":"Feature","geometry":{"type":"Point","coordinates":[6.188408,48.251786]}},
{"properties":{"libel_s":"Certilleux","slug_s":"Certilleux","uic_s":87674010,"pk":"56+303","rang":1,"idreseau":30000008560,"frevoy":"NN","num_s":"030000","dept":"88","nom_s":"Certilleux"},"type":"Feature","geometry":{"type":"Point","coordinates":[5.7194491232622635,48.31271488590898]}}
];
const sorprop = (a,b) => parseInt(a.properties.pk) - parseInt(b.properties.pk);
const printgare = (f,i) => (i?",\n":"\n") + JSON.stringify(f); //fp.libel_s +"-"+ parseInt(fp.pk);
const coli = "030000";
console.log(ff.reduce((acc,f,i) => acc + printgare(f,i), `[${ff.length}]: `));
let gg = ff.filter(f => f.properties.num_s === coli).sort((a,b) => parseInt(a.properties.pk) > parseInt(b.properties.pk));
console.log(gg.reduce((acc,f,i) => acc + printgare(f,i), `[${gg.length}]: `));
4

0 回答 0