fix: Replace Array.prototype.sort and update old isSorted method. (#39360)
* fix: Replace Array.prototype.sort and update old isSorted method. * fix: Change name of function from 'checkInBuiltSort' to 'checkBuilitInSort'. * fix: Change name of function from 'checkBuilitInSort' to 'isBuiltInSortUsed'.
This commit is contained in:
@ -43,10 +43,11 @@ tests:
|
||||
|
||||
```js
|
||||
// check if array is sorted
|
||||
function isSorted(arr) {
|
||||
var check = i =>
|
||||
i == arr.length - 1 ? true : arr[i] > arr[i + 1] ? false : check(i + 1);
|
||||
return check(0);
|
||||
function isSorted(a){
|
||||
for(let i = 0; i < a.length - 1; i++)
|
||||
if(a[i] > a[i + 1])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
// generate a randomly filled array
|
||||
var array = new Array();
|
||||
|
Reference in New Issue
Block a user