diff --git a/doc/api/util.md b/doc/api/util.md index f4f5f79f098f69..29ba65b760346e 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 = { diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index cd7d08caf0a0f8..1d37e97897dd34 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -1688,7 +1688,7 @@ assert.strictEqual( assert.strictEqual( inspect( { a200: 4, a100: 1, a102: 3, a101: 2 }, - { sorted(a, b) { return a < b; } } + { sorted(a, b) { return b.localeCompare(a); } } ), '{ a200: 4, a102: 3, a101: 2, a100: 1 }' );