Open Bug 1419710 Opened 2 years ago Updated 2 years ago

Array.prototype.sort confusing

Categories

(Developer Documentation :: JavaScript, enhancement, P5)

All
Other
enhancement

Tracking

(Not tracked)

UNCONFIRMED

People

(Reporter: computa_mike, Unassigned)

References

()

Details

(Keywords: testcase-wanted)

:: Developer Documentation Request

      Request Type: Correction
     Gecko Version: unspecified
 Technical Contact: 

:: Details

The opening line of this document states : 

The sort() method sorts the elements of an array in place and returns the array

This is confusing, as the method returns the sorted array, but also sorts it in place.  I have found that when an array I was sorting reached 15 items, that it no longer sorted in place, but did return a sorted array.  My code was sorting objects using a compare function - so that might be the issue.  Will try and add a codepen demonstrating the issue (assuming I can re-create the issue).
You need to log in before you can comment on or make changes to this bug.