You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pointer to a user-supplied routine that compares two array elements and returns a value that specifies their relationship.
40
41
41
42
## Remarks
42
43
43
-
The **qsort** function implements a quick-sort algorithm to sort an array of *number* elements, each of *width* bytes. The argument *base* is a pointer to the base of the array to be sorted. **qsort** overwrites this array by using the sorted elements.
44
+
The **`qsort`** function implements a quick-sort algorithm to sort an array of *`number`* elements, each of *`width`* bytes. The argument *`base`* is a pointer to the base of the array to be sorted. **`qsort`** overwrites this array by using the sorted elements.
44
45
45
-
**qsort** calls the *compare* routine one or more times during the sort, and passes pointers to two array elements on each call.
46
+
**`qsort`** calls the *`compare`* routine one or more times during the sort, and passes pointers to two array elements on each call. If *`compare`* indicates two elements are the same, their order in the resulting sorted array is unspecified.
46
47
47
48
```C
48
49
compare( (void *) & elem1, (void *) & elem2 );
@@ -52,21 +53,21 @@ The routine compares the elements and returns one of the following values.
The array is sorted in increasing order, as defined by the comparison function. To sort an array in decreasing order, reverse the sense of "greater than" and "less than" in the comparison function.
60
61
61
-
This function validates its parameters. If *compare* or *number* is **NULL**, or if *base* is **NULL** and *number* is nonzero, or if *width* is less than zero, the invalid parameter handler is invoked, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md). If execution is allowed to continue, the function returns and **errno** is set to **EINVAL**.
62
+
This function validates its parameters. If *`compare`* or *`number`* is **`NULL`**, or if *`base`* is **`NULL`** and *`number`* is nonzero, or if *`width`* is less than zero, the invalid parameter handler is invoked, as described in [Parameter Validation](../../c-runtime-library/parameter-validation.md). If execution is allowed to continue, the function returns and **`errno`** is set to **`EINVAL`**.
62
63
63
64
By default, this function's global state is scoped to the application. To change this, see [Global state in the CRT](../global-state.md).
64
65
65
66
## Requirements
66
67
67
68
|Routine|Required header|
68
69
|-------------|---------------------|
69
-
|**qsort**|\<stdlib.h> and \<search.h>|
70
+
|**`qsort`**|\<stdlib.h> and \<search.h>|
70
71
71
72
For additional compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
72
73
@@ -116,6 +117,6 @@ boy deserves every favor good
116
117
117
118
## See also
118
119
119
-
[Searching and Sorting](../../c-runtime-library/searching-and-sorting.md)<br/>
120
-
[bsearch](bsearch.md)<br/>
121
-
[_lsearch](lsearch.md)<br/>
120
+
[Searching and Sorting](../../c-runtime-library/searching-and-sorting.md)\
0 commit comments