JS implements alphabetical ordering of provinces and cities
A recent project has a requirement to sort the array of provinces and cities returned by the backend by the first letter (AZ). I referred to https://blog.csdn.net/kuangruike/article/details/54139694, which was written using JQuery Yes, I am using native js
1. The data returned by the backend
2. The last data obtained
That is, there are ten places under the initial letter "A"
3 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 = { lette