Skip to content

Commit 894eb59

Browse files
authored
Better Array.sort compareFn docs
1 parent d7c83f0 commit 894eb59

File tree

1 file changed

+30
-19
lines changed

1 file changed

+30
-19
lines changed

src/lib/es5.d.ts

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,9 @@ interface Array<T> {
12351235
slice(start?: number, end?: number): T[];
12361236
/**
12371237
* Sorts an array.
1238-
* @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order.
1238+
* @param compareFn Function used to determine the order of the elements. It is expected to return
1239+
* a negative value if first argument is less than second arguement, zero if they're equal and a positive
1240+
* value otherwise. If omitted, the elements are sorted in ascending, ASCII character order.
12391241
*/
12401242
sort(compareFn?: (a: T, b: T) => number): this;
12411243
/**
@@ -1876,8 +1878,9 @@ interface Int8Array {
18761878

18771879
/**
18781880
* Sorts an array.
1879-
* @param compareFn The name of the function used to determine the order of the elements. If
1880-
* omitted, the elements are sorted in ascending, ASCII character order.
1881+
* @param compareFn Function used to determine the order of the elements. It is expected to return
1882+
* a negative value if first argument is less than second arguement, zero if they're equal and a positive
1883+
* value otherwise. If omitted, the elements are sorted in ascending, ASCII character order.
18811884
*/
18821885
sort(compareFn?: (a: number, b: number) => number): this;
18831886

@@ -2151,8 +2154,9 @@ interface Uint8Array {
21512154

21522155
/**
21532156
* Sorts an array.
2154-
* @param compareFn The name of the function used to determine the order of the elements. If
2155-
* omitted, the elements are sorted in ascending, ASCII character order.
2157+
* @param compareFn Function used to determine the order of the elements. It is expected to return
2158+
* a negative value if first argument is less than second arguement, zero if they're equal and a positive
2159+
* value otherwise. If omitted, the elements are sorted in ascending, ASCII character order.
21562160
*/
21572161
sort(compareFn?: (a: number, b: number) => number): this;
21582162

@@ -2426,8 +2430,9 @@ interface Uint8ClampedArray {
24262430

24272431
/**
24282432
* Sorts an array.
2429-
* @param compareFn The name of the function used to determine the order of the elements. If
2430-
* omitted, the elements are sorted in ascending, ASCII character order.
2433+
* @param compareFn Function used to determine the order of the elements. It is expected to return
2434+
* a negative value if first argument is less than second arguement, zero if they're equal and a positive
2435+
* value otherwise. If omitted, the elements are sorted in ascending, ASCII character order.
24312436
*/
24322437
sort(compareFn?: (a: number, b: number) => number): this;
24332438

@@ -2699,8 +2704,9 @@ interface Int16Array {
26992704

27002705
/**
27012706
* Sorts an array.
2702-
* @param compareFn The name of the function used to determine the order of the elements. If
2703-
* omitted, the elements are sorted in ascending, ASCII character order.
2707+
* @param compareFn Function used to determine the order of the elements. It is expected to return
2708+
* a negative value if first argument is less than second arguement, zero if they're equal and a positive
2709+
* value otherwise. If omitted, the elements are sorted in ascending, ASCII character order.
27042710
*/
27052711
sort(compareFn?: (a: number, b: number) => number): this;
27062712

@@ -2975,8 +2981,9 @@ interface Uint16Array {
29752981

29762982
/**
29772983
* Sorts an array.
2978-
* @param compareFn The name of the function used to determine the order of the elements. If
2979-
* omitted, the elements are sorted in ascending, ASCII character order.
2984+
* @param compareFn Function used to determine the order of the elements. It is expected to return
2985+
* a negative value if first argument is less than second arguement, zero if they're equal and a positive
2986+
* value otherwise. If omitted, the elements are sorted in ascending, ASCII character order.
29802987
*/
29812988
sort(compareFn?: (a: number, b: number) => number): this;
29822989

@@ -3250,8 +3257,9 @@ interface Int32Array {
32503257

32513258
/**
32523259
* Sorts an array.
3253-
* @param compareFn The name of the function used to determine the order of the elements. If
3254-
* omitted, the elements are sorted in ascending, ASCII character order.
3260+
* @param compareFn Function used to determine the order of the elements. It is expected to return
3261+
* a negative value if first argument is less than second arguement, zero if they're equal and a positive
3262+
* value otherwise. If omitted, the elements are sorted in ascending, ASCII character order.
32553263
*/
32563264
sort(compareFn?: (a: number, b: number) => number): this;
32573265

@@ -3524,8 +3532,9 @@ interface Uint32Array {
35243532

35253533
/**
35263534
* Sorts an array.
3527-
* @param compareFn The name of the function used to determine the order of the elements. If
3528-
* omitted, the elements are sorted in ascending, ASCII character order.
3535+
* @param compareFn Function used to determine the order of the elements. It is expected to return
3536+
* a negative value if first argument is less than second arguement, zero if they're equal and a positive
3537+
* value otherwise. If omitted, the elements are sorted in ascending, ASCII character order.
35293538
*/
35303539
sort(compareFn?: (a: number, b: number) => number): this;
35313540

@@ -3799,8 +3808,9 @@ interface Float32Array {
37993808

38003809
/**
38013810
* Sorts an array.
3802-
* @param compareFn The name of the function used to determine the order of the elements. If
3803-
* omitted, the elements are sorted in ascending, ASCII character order.
3811+
* @param compareFn Function used to determine the order of the elements. It is expected to return
3812+
* a negative value if first argument is less than second arguement, zero if they're equal and a positive
3813+
* value otherwise. If omitted, the elements are sorted in ascending, ASCII character order.
38043814
*/
38053815
sort(compareFn?: (a: number, b: number) => number): this;
38063816

@@ -4075,8 +4085,9 @@ interface Float64Array {
40754085

40764086
/**
40774087
* Sorts an array.
4078-
* @param compareFn The name of the function used to determine the order of the elements. If
4079-
* omitted, the elements are sorted in ascending, ASCII character order.
4088+
* @param compareFn Function used to determine the order of the elements. It is expected to return
4089+
* a negative value if first argument is less than second arguement, zero if they're equal and a positive
4090+
* value otherwise. If omitted, the elements are sorted in ascending, ASCII character order.
40804091
*/
40814092
sort(compareFn?: (a: number, b: number) => number): this;
40824093

0 commit comments

Comments
 (0)