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

@ -91,8 +91,10 @@ function permutationSort(arr) {
}
}
function isSorted(a) {
for (var i = 1; i < a.length; i++) if (a[i - 1] > a[i]) return false;
function isSorted(a){
for(let i = 0; i < a.length - 1; i++)
if(a[i] > a[i + 1])
return false;
return true;
}