# Not using built-in sort() method

I think there could be a problem with the tests for this algorithm Implement Quick Sort: I wrote code that followed one of the solutions very closely. It works well on my own machine, but when I run it through FCC’s tests, I keep getting this error:

`quickSort should not use the built-in .sort() method.`

As you can see below, I am not using .sort():

``````if (array.length === 0) {

return [];

} else {

const pivotVal = array[0];

//sort elements into three arrays

let lesserArr = [];

let equalArr = [];

let greaterArr =[];

for (let e of array) {

if (e < pivotVal) {

lesserArr.push(e);

} else if (e > pivotVal) {

greaterArr.push(e)

} else {

equalArr.push(e);

}

}

array = [...quickSort(lesserArr), ...equalArr, ...quickSort(greaterArr)]

}
``````

Any help would be much appreciated. Thanks, Mark

do not use the characters `sort` anywhere, in comments, variable names etc

remove those and see if it passes

Thanks for the idea, but I thought the point here was to use recursion. If the function is called quickSort, and we are encouraged to use recursion, is not “sort” in the function inevitable?

the tests check for the word `sort` in the editor to know if you have used the sort method or not.
Remove the comment that contains the `sort` word

Thanks. I understood what you meant the first time. My question is why would such a test be included, when the exercise is about recursion and the function is called quickSort(), which includes the word “sort”?

I removed any appearance of “sort” from my function, but it still does not pass the “sort()” test; and it works fine on my local machine. Here is my code:

``````function quickSort(array) {
// change code below this line
function mything(array) {
if (array.length === 0) {
return array;
} else {
const pivotVal = array[0];
//sort elements into three arrays
let lesserArr = [];
let equalArr = [];
let greaterArr =[];
for (let e of array) {
if (e < pivotVal) {
lesserArr.push(e);
} else if (e > pivotVal) {
greaterArr.push(e)
} else {
equalArr.push(e);
}
}
array = [...mything(lesserArr), ...equalArr, ...mything(greaterArr)]
}
// change code above this line
return array;
}
return mything(array);
}`````````

Cheers! (Post must be at least 20 characters)

In code capitalization matter, the native method is called `sort`, so you can’t use the `sort` word (the hard ban was used to avoid renaming of the method and then be able to use it)
if you use `Sort` or any other capitalization that is not all lower case, then it’s fine

you still need to remove the comment containing the word `sort`

Hello Igor and magical girl!
Thank you! I did not realize the test would read comments. It works now.
take care, Mark