'use strict'; var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); var uncurryThis = require('../internals/function-uncurry-this'); var aCallable = require('../internals/a-callable'); var arrayFromConstructorAndList = require('../internals/array-from-constructor-and-list'); var aTypedArray = ArrayBufferViewCore.aTypedArray; var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor; var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; var sort = uncurryThis(ArrayBufferViewCore.TypedArrayPrototype.sort); // `%TypedArray%.prototype.toSorted` method // https://tc39.es/ecma262/#sec-%typedarray%.prototype.tosorted exportTypedArrayMethod('toSorted', function toSorted(compareFn) { if (compareFn !== undefined) aCallable(compareFn); var O = aTypedArray(this); var A = arrayFromConstructorAndList(getTypedArrayConstructor(O), O); return sort(A, compareFn); });