React Native localeCompare not working on Android

Viewed 2019

I am trying sort my array alphabetically.

myArray.sort(function(a, b){
    return a.title.localeCompare(b.title ,'tr');
  })

myArray includes turkish characters like 'ç,ş,ü,ö,ı'. My code works correctly on ios but it doesn't work the way i want it on android. It sort alphabatically but words starting with turkish characters are at the bottom of list.

2 Answers

I'm having the same issue with latest RN 0.61.5 on Android.

I ended up using lodash deburr to remove accented chars from my strings and I then call String.localCompare on deburred strings. It seems to do the job so far...

Related