Last active
September 5, 2018 08:37
-
-
Save caryfuk/163f6d69f70c1ffb20bb152fc6755606 to your computer and use it in GitHub Desktop.
getting rid of diacritics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* https://thread.engineering/searching-and-sorting-text-with-diacritical-marks-in-javascript-45afef20e7f2 */ | |
const animal = 'žluťoučký kůň'.normalize('NFD').replace(/[\u0300-\u036f]/g, ''); | |
/* sorting with locale */ | |
arr.sort((a, b) => a.localeCompare(b)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment