You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
648 B
JavaScript
23 lines
648 B
JavaScript
'use strict';
|
|
var $export = require('./_export')
|
|
, aFunction = require('./_a-function')
|
|
, toObject = require('./_to-object')
|
|
, fails = require('./_fails')
|
|
, $sort = [].sort
|
|
, test = [1, 2, 3];
|
|
|
|
$export($export.P + $export.F * (fails(function(){
|
|
// IE8-
|
|
test.sort(undefined);
|
|
}) || !fails(function(){
|
|
// V8 bug
|
|
test.sort(null);
|
|
// Old WebKit
|
|
}) || !require('./_strict-method')($sort)), 'Array', {
|
|
// 22.1.3.25 Array.prototype.sort(comparefn)
|
|
sort: function sort(comparefn){
|
|
return comparefn === undefined
|
|
? $sort.call(toObject(this))
|
|
: $sort.call(toObject(this), aFunction(comparefn));
|
|
}
|
|
}); |