diff options
author | Michaël Zasso <targos@protonmail.com> | 2018-09-21 10:40:42 +0200 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2018-09-22 14:29:37 +0200 |
commit | e758d4ab0adf53f2a4b736433714943bc4b4f06f (patch) | |
tree | b350211f3c0999cc30733eea3419d99a18bd44ac /doc/api/util.md | |
parent | 36bdd19a6b3aee18143a3d45d6eedc19a2e95189 (diff) | |
download | android-node-v8-e758d4ab0adf53f2a4b736433714943bc4b4f06f.tar.gz android-node-v8-e758d4ab0adf53f2a4b736433714943bc4b4f06f.tar.bz2 android-node-v8-e758d4ab0adf53f2a4b736433714943bc4b4f06f.zip |
doc,test: fix inspect's sorted compare function
In V8 7.0, the array sorting algorithm was changed to Timsort, which
is stable. A compare function returning only `true` or `false`
(converted to 0 and 1) cannot work properly.
PR-URL: https://github.com/nodejs/node/pull/22992
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Kyle Farnung <kfarnung@microsoft.com>
Diffstat (limited to 'doc/api/util.md')
-rw-r--r-- | doc/api/util.md | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/doc/api/util.md b/doc/api/util.md index f4f5f79f09..29ba65b760 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -556,7 +556,7 @@ const o1 = { }; console.log(inspect(o1, { sorted: true })); // { a: '`a` comes before `b`', b: [ 2, 3, 1 ], c: Set { 1, 2, 3 } } -console.log(inspect(o1, { sorted: (a, b) => a < b })); +console.log(inspect(o1, { sorted: (a, b) => b.localeCompare(a) })); // { c: Set { 3, 2, 1 }, b: [ 2, 3, 1 ], a: '`a` comes before `b`' } const o2 = { |