there should be a small test at init time to see if the ICU collator works for Tibetan, and then use that instead of the JS code if available. This code seems to indicate that it works in modern browsers:
var tibCollator = new Intl.Collator('bo');
var tibSortedArray = ["ང", "རྔ", "ལྔ", "སྔ", "བརྔ", "བསྔ", "ཅ"];
var tibRandomArray = ["ལྔ", "ང", "ཅ", "རྔ", "སྔ", "བརྔ", "བསྔ"];
var tibResultArray = ["ལྔ", "ང", "ཅ", "རྔ", "སྔ", "བརྔ", "བསྔ"];
tibResultArray.sort(tibCollator.compare);
var resPrint = "";
if (JSON.stringify(tibSortedArray)==JSON.stringify(tibResultArray)) {
resPrint = "ok!";
} else {
resPrint = "error: "+JSON.stringify(tibRandomArray)+" has been sorted as "+JSON.stringify(tibResultArray)+", should have been "+JSON.stringify(tibSortedArray);
}
console.log(resPrint);
there should be a small test at init time to see if the ICU collator works for Tibetan, and then use that instead of the JS code if available. This code seems to indicate that it works in modern browsers:
see https://www.bdrc.io/blog/2021/10/29/sorting-out-tibetan-alphabetical-order/