缩小到最大聚合,安卓手机就是50+,苹果手机能准确到个位数
小程序点聚合安卓手机和苹果手机不一样?[图片][图片][图片]
2020-10-31this.pySegSort( [ "张1", "张3", "张4", "张三"]) 这样调用
姓名排序localeCompare,苹果和安卓结果不一样,救救孩子吧?[代码]function pySegSort(arr) { [代码] [代码] if(!String.prototype.localeCompare)[代码] [代码] return null; [代码] [代码] var letters = "*abcdefghjklmnopqrstwxyz".split(''); [代码] [代码] var zh = "阿八嚓哒妸发旮哈讥咔垃痳拏噢妑七呥扨它穵夕丫帀".split(''); [代码] [代码] var segs = []; var curr; letters.forEach(function(item,i){ curr = {letter: item, data:[]};[代码][代码] arr.forEach(function(item2){ [代码] [代码] if((!zh[i-1] || zh[i-1].localeCompare(item2) <= 0) && item2.localeCompare(zh[i]) == -1) {[代码] [代码] curr.data.push(item2); }[代码][代码] });[代码] [代码] if(curr.data.length) {[代码] [代码] segs.push(curr);[代码][代码] curr.data.sort(function(a,b){[代码] [代码] return a.localeCompare(b);[代码] [代码] }); } }); return segs; }[代码]
2019-09-06