1

MDN states that Array.prototype.sort() sorts by UTF-16.

"The default sort order is ascending [...] comparing their sequences of UTF-16 code units values."

I need to be able to sort by UTF-8. Is there a good way to do this in the browser?

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort

Zamicol
  • 3,891
  • 1
  • 31
  • 36
  • 1
    Does this answer your question? [How to overload comparator to sort with UTF-8 and different locales](https://stackoverflow.com/questions/41242116/how-to-overload-comparator-to-sort-with-utf-8-and-different-locales) – Heretic Monkey May 07 '21 at 21:12

1 Answers1

1

To do that you would have to write your own sorting method, like here.

But JS has no built-in UTF-8 sorting method, and I couldn't find any libraries.

Doumor
  • 339
  • 1
  • 11