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:
Kartik Soneji
2020-08-11 02:01:18 +05:30
committed by GitHub
parent 8996fa7502
commit f813dfff87
17 changed files with 172 additions and 73 deletions

View File

@ -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();