Skip to content

Commit 6e1805d

Browse files
committed
Add sort compare function with explicit type cast
1 parent 1ea3d29 commit 6e1805d

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

JavaScript/9-bigint.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ console.log();
5151
const array1 = [-2, 7, 1n, 3, -2n, 8n, 5, -4n];
5252
console.log(array1);
5353
console.log(array1.sort());
54+
console.log(array1.sort((a, b) => BigInt(a) - BigInt(b)));
5455
console.log();
5556

5657
// https://github.com/tc39/proposal-bigint

0 commit comments

Comments
 (0)