Skip to content

Instantly share code, notes, and snippets.

@caryfuk
Last active September 5, 2018 08:37
Show Gist options
  • Save caryfuk/163f6d69f70c1ffb20bb152fc6755606 to your computer and use it in GitHub Desktop.
Save caryfuk/163f6d69f70c1ffb20bb152fc6755606 to your computer and use it in GitHub Desktop.
getting rid of diacritics
/* 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