Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

orderBy not supported persian language #14455

Closed
captainhamid opened this issue Apr 18, 2016 · 5 comments
Closed

orderBy not supported persian language #14455

captainhamid opened this issue Apr 18, 2016 · 5 comments

Comments

@captainhamid
Copy link

filter orderBy not supported persian language,
orderBy ignore letters "گ چ پ ژ".

@gkalpak
Copy link
Member

gkalpak commented Apr 18, 2016

Could you please create a live demo (e.g. using CodePen, plnkr etc), so we can reproduce and investigate the problem ?

@captainhamid
Copy link
Author

captainhamid commented Apr 19, 2016

demo : http://codepen.io/captianhamid/pen/grzZpM
correct sort is:

  1. احمد
    2.پروین
    3.ترانه
    4.حمید
    5.ژاله
    6.ساسان
    7.گوهر
    8.مهران
    but angular ignore letters "گ چ پ ژ".
    more information Persian alphabet: https://en.wikipedia.org/wiki/Persian_alphabet

@mrak1001
Copy link

I have same problem.
angular ignore letters "گ چ پ ژ".

@behnammodi
Copy link

behnammodi commented Apr 19, 2016

hi this problem for javascript. just solution overwrite sort and bind

موفق باشید

3

@gkalpak
Copy link
Member

gkalpak commented Apr 19, 2016

This is because of how JS orders the strings (in a locale-unaware way).
One could use String.prototype.localeCompare, but then you could get different results based on the user's locale.

Ideally, orderBy could accept a custom comparator function, so you could define your comparing logic there (and use localeCompare or whatever would produce correct results for your particular usecase).
Since this is not supported (yet 😛), you should create a custom filter.

@gkalpak gkalpak modified the milestones: Backlog, Purgatory Apr 19, 2016
gkalpak added a commit to gkalpak/angular.js that referenced this issue Apr 19, 2016
With this change the 3rd argument is interpreted as a comparator function, used to compare the
values returned by the predicates. Leaving it empty falls back to the default comparator and a
value of `false` is a special case that also falls back to the default comparator but reverses the
order. Thus the new implementation is backwards compatible.

Helps with angular#12572 (maybe this is as close as we want to get).

Fixes angular#13238
Fixes angular#14455

Closes angular#5123
Closes angular#8112
Closes angular#10368
gkalpak added a commit to gkalpak/angular.js that referenced this issue Apr 21, 2016
With this change the 3rd argument is interpreted as a comparator function, used to compare the
values returned by the predicates. Leaving it empty falls back to the default comparator and a
value of `false` is a special case that also falls back to the default comparator but reverses the
order. Thus the new implementation is backwards compatible.

This commit also xpands the documentation to cover the algorithm used to sort elements and adds
a few more unit and e2e tests (unrelated to the change).

Helps with angular#12572 (maybe this is as close as we want to get).

Fixes angular#13238
Fixes angular#14455

Closes angular#5123
Closes angular#8112
Closes angular#10368
gkalpak added a commit to gkalpak/angular.js that referenced this issue Apr 21, 2016
With this change the 3rd argument is interpreted as a comparator function, used to compare the
values returned by the predicates. Leaving it empty falls back to the default comparator and a
value of `false` is a special case that also falls back to the default comparator but reverses the
order. Thus the new implementation is backwards compatible.

This commit also expands the documentation to cover the algorithm used to sort elements and adds
a few more unit and e2e tests (unrelated to the change).

Helps with angular#12572 (maybe this is as close as we want to get).

Fixes angular#13238
Fixes angular#14455

Closes angular#5123
Closes angular#8112
Closes angular#10368
@gkalpak gkalpak closed this as completed in 48c8b23 Jun 6, 2016
gkalpak added a commit that referenced this issue Jun 6, 2016
Add an optional, 4th argument (`comparator`) for specifying a custom comparator function, used to
compare the values returned by the predicates. Omitting the argument, falls back to the default,
built-in comparator. The 3rd argument (`reverse`) can still be used for controlling the sorting
order (i.e. ascending/descending).

Additionally, the documentation has been expanded to cover the algorithm used by the built-in
comparator and a few more unit and e2e tests (unrelated to the change) have been added.

Helps with #12572 (maybe this is as close as we want to get).

Fixes #13238
Fixes #14455

Closes #5123
Closes #8112
Closes #10368

Closes #14468
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants