1

I'm trying to sort my array by group and then identifier fields, which works fine, until one of the strings contains a special character, for example Á or Ű.

Is there any kind of typescript or ng-2 specific method or sth to solve my problem?

Example sorting method:

private someSortingMethod(): void {
        this.sortable= this.sortable.sort((t1: SomeThing, t2: SomeThing): number => {
            if (t1.group < t2.group) return -1;
            if (t1.group > t2.group) return 1;
            if (t1.identifier < t2.identifier) return -1;
            if (t1.identifier > t2.identifier) return 1;
            return 0;
        });
    }

Thank you.

1
  • 1
    What is your input, what do you expect the output to be, and what is your actual output? What is the problem? Commented Aug 21, 2017 at 16:46

1 Answer 1

1

There's a package on npm that does what you need:

var removeDiacritics = require('diacritics').remove;
console.log(removeDiacritics("Iлtèrnåtïonɑlíƶatï߀ԉ"));
// prints "Internationalizati0n" 

https://www.npmjs.com/package/diacritics

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.