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

feat(orderBy): support sorting of umlauts #5123

Closed

Conversation

salzig
Copy link

@salzig salzig commented Nov 25, 2013

Compare Strings using the localeCompare method if available.

@mary-poppins
Copy link

Thanks for the PR!

  • Contributor signed CLA now or in the past
    • If you just signed, leave a comment here with your real name
  • PR's commit messages follow the commit message format

If you need to make changes to your pull request, you can update the commit with git commit --amend.
Then, update the pull request with git push -f.

Thanks again for your help!

@salzig
Copy link
Author

salzig commented Nov 25, 2013

real name: Ben Rexin

ps: your CLA-Form could ask for the Github Username. :)

@petebacondarwin
Copy link
Contributor

How does this take into account the locale when comparing, if we don't provide a locale as a second parameter?
Also I wonder if localeCompare is going to kill performance?

@salzig
Copy link
Author

salzig commented Nov 25, 2013

This is just a minimal implementation to get the test green, feel free to suggest improvements.

According to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare Firefox and Safari don't handle the optional parameters. In a short test, firefox just ignores additional parameters.

This function is intended to rely on whatever language-sensitive comparison functionality is available to the ECMAScript environment from the host environment, and to compare according to the rules of the host environment’s current locale. It is strongly recommended that this function treat Strings that are canonically equivalent according to the Unicode standard as identical (in other words, compare the Strings as if they had both been converted to Normalised Form C or D first). It is also recommended that this function not honour Unicode compatibility equivalences or decompositions.
– NOTE 2 - http://ecma-international.org/ecma-262/5.1/#sec-15.5.4.9

Compare Strings using the localeCompare method if available.
@btford btford removed the gh: PR label Aug 20, 2014
@jeffbcross jeffbcross force-pushed the master branch 2 times, most recently from cad9560 to f294244 Compare October 2, 2014 22:08
@jeffbcross jeffbcross force-pushed the master branch 4 times, most recently from e8dc429 to e83fab9 Compare October 10, 2014 17:37
gkalpak added a commit to gkalpak/angular.js that referenced this pull request 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 pull request 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 pull request 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 in 48c8b23 Jun 6, 2016
gkalpak added a commit that referenced this pull request 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 this pull request may close these issues.

5 participants