diff --git a/lib/node_modules/@stdlib/blas/ext/to-sorted/README.md b/lib/node_modules/@stdlib/blas/ext/to-sorted/README.md
new file mode 100644
index 000000000000..58c55f44e653
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sorted/README.md
@@ -0,0 +1,209 @@
+
+
+# toSorted
+
+> Return a new [ndarray][@stdlib/ndarray/ctor] containing the elements of an input [ndarray][@stdlib/ndarray/ctor] sorted along one or more [ndarray][@stdlib/ndarray/ctor] dimensions.
+
+
+
+## Usage
+
+```javascript
+var toSorted = require( '@stdlib/blas/ext/to-sorted' );
+```
+
+#### toSorted( x\[, sortOrder]\[, options] )
+
+Returns a new [ndarray][@stdlib/ndarray/ctor] containing the elements of an input [ndarray][@stdlib/ndarray/ctor] sorted along one or more [ndarray][@stdlib/ndarray/ctor] dimensions.
+
+```javascript
+var array = require( '@stdlib/ndarray/array' );
+
+var x = array( [ -1.0, 2.0, -3.0 ] );
+
+var y = toSorted( x );
+// returns [ -3.0, -1.0, 2.0 ]
+```
+
+The function has the following parameters:
+
+- **x**: input [ndarray][@stdlib/ndarray/ctor]. Must have a real-valued or "generic" [data type][@stdlib/ndarray/dtypes].
+- **sortOrder**: sort order (_optional_). May be either a scalar value, string, or an [ndarray][@stdlib/ndarray/ctor] having a real-valued or "generic" [data type][@stdlib/ndarray/dtypes]. If provided an [ndarray][@stdlib/ndarray/ctor], the value must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the complement of the shape defined by `options.dims`. For example, given the input shape `[2, 3, 4]` and `options.dims=[0]`, an [ndarray][@stdlib/ndarray/ctor] sort order must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the shape `[3, 4]`. Similarly, when performing the operation over all elements in a provided input [ndarray][@stdlib/ndarray/ctor], an [ndarray][@stdlib/ndarray/ctor] sort order must be a zero-dimensional [ndarray][@stdlib/ndarray/ctor]. By default, the sort order is `1` (i.e., increasing order).
+- **options**: function options (_optional_).
+
+The function accepts the following options:
+
+- **dims**: list of dimensions over which to perform operation. If not provided, the function performs the operation over all elements in a provided input [ndarray][@stdlib/ndarray/ctor].
+- **dtype**: output [ndarray][@stdlib/ndarray/ctor] [data type][@stdlib/ndarray/dtypes].
+
+By default, the function sorts elements in increasing order. To sort in a different order, provide a `sortOrder` argument.
+
+```javascript
+var array = require( '@stdlib/ndarray/array' );
+
+var x = array( [ -1.0, 2.0, -3.0 ] );
+
+var y = toSorted( x, -1.0 );
+// returns [ 2.0, -1.0, -3.0 ]
+```
+
+In addition to numeric values, one can specify the sort order via one of the following string literals: `'ascending'`, `'asc'`, `'descending'`, or `'desc'`. The first two literals indicate to sort in ascending (i.e., increasing) order. The last two literals indicate to sort in descending (i.e., decreasing) order.
+
+```javascript
+var array = require( '@stdlib/ndarray/array' );
+
+var x = array( [ -1.0, 2.0, -3.0 ] );
+
+// Sort in ascending order:
+var y = toSorted( x, 'asc' );
+// returns [ -3.0, -1.0, 2.0 ]
+
+// Sort in descending order:
+y = toSorted( x, 'descending' );
+// returns [ 2.0, -1.0, -3.0 ]
+```
+
+By default, the function performs the operation over all elements in a provided input [ndarray][@stdlib/ndarray/ctor]. To perform the operation over specific dimensions, provide a `dims` option.
+
+```javascript
+var array = require( '@stdlib/ndarray/array' );
+
+var x = array( [ -1.0, 2.0, -3.0, 4.0 ], {
+ 'shape': [ 2, 2 ],
+ 'order': 'row-major'
+});
+
+var y = toSorted( x, {
+ 'dims': [ 0 ]
+});
+// returns [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ]
+```
+
+To specify the output [ndarray][@stdlib/ndarray/ctor] [data type][@stdlib/ndarray/dtypes], provide a `dtype` option.
+
+```javascript
+var array = require( '@stdlib/ndarray/array' );
+
+var x = array( [ -1.0, 2.0, -3.0 ] );
+
+var y = toSorted( x, {
+ 'dtype': 'float32'
+});
+// returns [ -3.0, -1.0, 2.0 ]
+```
+
+#### toSorted.assign( x\[, sortOrder], out\[, options] )
+
+Sorts the elements of an input [ndarray][@stdlib/ndarray/ctor] along one or more [ndarray][@stdlib/ndarray/ctor] dimensions and assigns the results to an output [ndarray][@stdlib/ndarray/ctor].
+
+```javascript
+var zeros = require( '@stdlib/ndarray/zeros' );
+var array = require( '@stdlib/ndarray/array' );
+
+var x = array( [ -1.0, 2.0, -3.0 ] );
+var y = zeros( [ 3 ] );
+
+var out = toSorted.assign( x, y );
+// returns [ -3.0, -1.0, 2.0 ]
+
+var bool = ( y === out );
+// returns true
+```
+
+The function has the following parameters:
+
+- **x**: input [ndarray][@stdlib/ndarray/ctor]. Must have a real-valued or "generic" [data type][@stdlib/ndarray/dtypes].
+- **sortOrder**: sort order (_optional_). May be either a scalar value, string, or an [ndarray][@stdlib/ndarray/ctor] having a real-valued or "generic" [data type][@stdlib/ndarray/dtypes]. If provided an [ndarray][@stdlib/ndarray/ctor], the value must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the complement of the shape defined by `options.dims`. For example, given the input shape `[2, 3, 4]` and `options.dims=[0]`, an [ndarray][@stdlib/ndarray/ctor] sort order must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the shape `[3, 4]`. Similarly, when performing the operation over all elements in a provided input [ndarray][@stdlib/ndarray/ctor], an [ndarray][@stdlib/ndarray/ctor] sort order must be a zero-dimensional [ndarray][@stdlib/ndarray/ctor]. By default, the sort order is `1` (i.e., increasing order).
+- **out**: output [ndarray][@stdlib/ndarray/ctor]. Must have a real-valued or "generic" [data type][@stdlib/ndarray/dtypes].
+- **options**: function options (_optional_).
+
+The function accepts the following options:
+
+- **dims**: list of dimensions over which to perform operation. If not provided, the function performs the operation over all elements in a provided input [ndarray][@stdlib/ndarray/ctor].
+
+
+
+
+
+
+
+## Notes
+
+- If `sortOrder < 0.0` or is either `'desc'` or `'descending'`, the input [ndarray][@stdlib/ndarray/ctor] is sorted in **decreasing** order. If `sortOrder > 0.0` or is either `'asc'` or `'ascending'`, the input [ndarray][@stdlib/ndarray/ctor] is sorted in **increasing** order. If `sortOrder == 0.0`, the input [ndarray][@stdlib/ndarray/ctor] is left unchanged.
+- The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`.
+- The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first.
+- The function iterates over [ndarray][@stdlib/ndarray/ctor] elements according to the memory layout of the input [ndarray][@stdlib/ndarray/ctor]. Accordingly, performance degradation is possible when operating over multiple dimensions of a large non-contiguous multi-dimensional input [ndarray][@stdlib/ndarray/ctor]. In such scenarios, one may want to copy an input [ndarray][@stdlib/ndarray/ctor] to contiguous memory before sorting.
+
+
+
+
+
+
+
+## Examples
+
+
+
+```javascript
+var discreteUniform = require( '@stdlib/random/discrete-uniform' );
+var ndarray2array = require( '@stdlib/ndarray/to-array' );
+var toSorted = require( '@stdlib/blas/ext/to-sorted' );
+
+// Generate an ndarray of random numbers:
+var x = discreteUniform( [ 5, 5 ], -20, 20, {
+ 'dtype': 'generic'
+});
+console.log( ndarray2array( x ) );
+
+// Perform operation:
+var out = toSorted( x, {
+ 'dims': [ 0 ]
+});
+
+// Print the results:
+console.log( ndarray2array( out ) );
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/ctor
+
+[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/dtypes
+
+[@stdlib/ndarray/base/broadcast-shapes]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/broadcast-shapes
+
+
+
+
diff --git a/lib/node_modules/@stdlib/blas/ext/to-sorted/benchmark/benchmark.assign.js b/lib/node_modules/@stdlib/blas/ext/to-sorted/benchmark/benchmark.assign.js
new file mode 100644
index 000000000000..d3352da8d1db
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sorted/benchmark/benchmark.assign.js
@@ -0,0 +1,109 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var uniform = require( '@stdlib/random/uniform' );
+var zeros = require( '@stdlib/ndarray/zeros' );
+var format = require( '@stdlib/string/format' );
+var pkg = require( './../package.json' ).name;
+var assign = require( './../lib/assign.js' );
+
+
+// VARIABLES //
+
+var options = {
+ 'dtype': 'float64'
+};
+
+
+// FUNCTIONS //
+
+/**
+* Creates a benchmark function.
+*
+* @private
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( len ) {
+ var x;
+ var y;
+
+ x = uniform( [ len ], -50.0, 50.0, options );
+ y = zeros( [ len ], options );
+
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var o;
+ var i;
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ o = assign( x, ( i%2 ) ? 1 : -1, y );
+ if ( typeof o !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( isnan( y.get( i%len ) ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ min = 1; // 10^min
+ max = 6; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( len );
+ bench( format( '%s:assign:dtype=%s,len=%d', pkg, options.dtype, len ), f );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/to-sorted/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/to-sorted/benchmark/benchmark.js
new file mode 100644
index 000000000000..c13161c2a759
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sorted/benchmark/benchmark.js
@@ -0,0 +1,103 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var uniform = require( '@stdlib/random/uniform' );
+var format = require( '@stdlib/string/format' );
+var pkg = require( './../package.json' ).name;
+var toSorted = require( './../lib' );
+
+
+// VARIABLES //
+
+var options = {
+ 'dtype': 'float64'
+};
+
+
+// FUNCTIONS //
+
+/**
+* Creates a benchmark function.
+*
+* @private
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( len ) {
+ var x = uniform( [ len ], -50.0, 50.0, options );
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var o;
+ var i;
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ o = toSorted( x, ( i%2 ) ? 1 : -1 );
+ if ( typeof o !== 'object' ) {
+ b.fail( 'should return an ndarray' );
+ }
+ }
+ b.toc();
+ if ( isnan( o.get( i%len ) ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ min = 1; // 10^min
+ max = 6; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( len );
+ bench( format( '%s:dtype=%s,len=%d', pkg, options.dtype, len ), f );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/to-sorted/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/to-sorted/docs/repl.txt
new file mode 100644
index 000000000000..bf5df08719a5
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sorted/docs/repl.txt
@@ -0,0 +1,115 @@
+
+{{alias}}( x[, sortOrder][, options] )
+ Returns a new ndarray containing the elements of an input ndarray sorted
+ along one or more ndarray dimensions.
+
+ The algorithm distinguishes between `-0` and `+0`. When sorted in increasing
+ order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is
+ sorted after `+0`.
+
+ The algorithm sorts `NaN` values to the end. When sorted in increasing
+ order, `NaN` values are sorted last. When sorted in decreasing order, `NaN`
+ values are sorted first.
+
+ Parameters
+ ----------
+ x: ndarray
+ Input array. Must have a real-valued or "generic" data type.
+
+ sortOrder: ndarray|number|string (optional)
+ Sort order. May be either a scalar value, string, or an ndarray having a
+ real-valued or "generic" data type. If provided an ndarray, the value
+ must have a shape which is broadcast compatible with the complement of
+ the shape defined by `options.dims`. For example, given the input shape
+ `[2, 3, 4]` and `options.dims=[0]`, an ndarray sort order must have a
+ shape which is broadcast compatible with the shape `[3, 4]`. Similarly,
+ when performing the operation over all elements in a provided input
+ ndarray, an ndarray sort order must be a zero-dimensional ndarray.
+
+ If specified as a string, must be one of the following values:
+
+ - ascending: sort in increasing order.
+ - asc: sort in increasing order.
+ - descending: sort in decreasing order.
+ - desc: sort in decreasing order.
+
+ By default, the sort order is `1` (i.e., increasing order).
+
+ options: Object (optional)
+ Function options.
+
+ options.dims: Array (optional)
+ List of dimensions over which to perform operation. If not provided, the
+ function performs the operation over all elements in a provided input
+ ndarray.
+
+ options.dtype: string|DataType (optional)
+ Output array data type.
+
+ Returns
+ -------
+ out: ndarray
+ Output array.
+
+ Examples
+ --------
+ > var x = {{alias:@stdlib/ndarray/array}}( [ -1.0, 2.0, -3.0, -4.0 ] );
+ > var out = {{alias}}( x )
+ [ -4.0, -3.0, -1.0, 2.0 ]
+
+
+{{alias}}.assign( x[, sortOrder], out[, options] )
+ Sorts elements of an input ndarray along one or more ndarray dimensions and
+ assigns the results to an output ndarray.
+
+ Parameters
+ ----------
+ x: ndarray
+ Input array. Must have a real-valued or "generic" data type.
+
+ sortOrder: ndarray|number|string (optional)
+ Sort order. May be either a scalar value, string, or an ndarray having a
+ real-valued or "generic" data type. If provided an ndarray, the value
+ must have a shape which is broadcast compatible with the complement of
+ the shape defined by `options.dims`. For example, given the input shape
+ `[2, 3, 4]` and `options.dims=[0]`, an ndarray sort order must have a
+ shape which is broadcast compatible with the shape `[3, 4]`. Similarly,
+ when performing the operation over all elements in a provided input
+ ndarray, an ndarray sort order must be a zero-dimensional ndarray.
+
+ If specified as a string, must be one of the following values:
+
+ - ascending: sort in increasing order.
+ - asc: sort in increasing order.
+ - descending: sort in decreasing order.
+ - desc: sort in decreasing order.
+
+ By default, the sort order is `1` (i.e., increasing order).
+
+ out: ndarray
+ Output array. Must have a real-valued or "generic" data type.
+
+ options: Object (optional)
+ Function options.
+
+ options.dims: Array (optional)
+ List of dimensions over which to perform operation. If not provided, the
+ function performs the operation over all elements in a provided input
+ ndarray.
+
+ Returns
+ -------
+ out: ndarray
+ Output array.
+
+ Examples
+ --------
+ > var x = {{alias:@stdlib/ndarray/array}}( [ -1.0, 2.0, -3.0, -4.0 ] );
+ > var y = {{alias:@stdlib/ndarray/zeros}}( [ 4 ] );
+ > var out = {{alias}}.assign( x, y )
+ [ -4.0, -3.0, -1.0, 2.0 ]
+ > var bool = ( out === y )
+ true
+
+ See Also
+ --------
diff --git a/lib/node_modules/@stdlib/blas/ext/to-sorted/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/to-sorted/docs/types/index.d.ts
new file mode 100644
index 000000000000..c4b0d6723d97
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sorted/docs/types/index.d.ts
@@ -0,0 +1,273 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+// TypeScript Version: 4.1
+
+///
+
+import { ArrayLike } from '@stdlib/types/array';
+import { RealAndGenericDataType as DataType, typedndarray, realndarray, genericndarray } from '@stdlib/types/ndarray';
+
+/**
+* Input array.
+*/
+type InputArray = realndarray | genericndarray;
+
+/**
+* Output array.
+*/
+type OutputArray = realndarray | genericndarray;
+
+/**
+* Sort order.
+*/
+type SortOrder = typedndarray | genericndarray | number | 'descending' | 'desc' | 'ascending' | 'asc';
+
+/**
+* Interface defining "base" options.
+*/
+interface BaseOptions {
+ /**
+ * List of dimensions over which to perform operation.
+ */
+ dims?: ArrayLike;
+}
+
+/**
+* Interface defining options.
+*/
+interface Options extends BaseOptions {
+ /**
+ * Output ndarray data type.
+ */
+ dtype: DataType;
+}
+
+/**
+* Interface for performing an operation on an ndarray.
+*/
+interface ToSorted {
+ /**
+ * Returns a new ndarray containing the elements of an input ndarray sorted along one or more ndarray dimensions.
+ *
+ * ## Notes
+ *
+ * - If `sortOrder < 0.0` or is either `'desc'` or `'descending'`, the input ndarray is sorted in **decreasing** order. If `sortOrder > 0.0` or is either `'asc'` or `'ascending'`, the input ndarray is sorted in **increasing** order. If `sortOrder == 0.0`, the input ndarray is left unchanged.
+ * - The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`.
+ * - The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first.
+ *
+ * @param x - input ndarray
+ * @param options - function options
+ * @returns output ndarray
+ *
+ * @example
+ * var array = require( '@stdlib/ndarray/array' );
+ *
+ * var x = array( [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ] );
+ * // returns [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ]
+ *
+ * var out = toSorted( x );
+ * // returns [ [ [ -5.0, -3.0 ] ], [ [ 1.0, 2.0 ] ], [ [ 4.0, 6.0 ] ] ]
+ */
+ ( x: T, options?: BaseOptions ): T;
+
+ /**
+ * Returns a new ndarray containing the elements of an input ndarray sorted along one or more ndarray dimensions.
+ *
+ * ## Notes
+ *
+ * - If `sortOrder < 0.0` or is either `'desc'` or `'descending'`, the input ndarray is sorted in **decreasing** order. If `sortOrder > 0.0` or is either `'asc'` or `'ascending'`, the input ndarray is sorted in **increasing** order. If `sortOrder == 0.0`, the input ndarray is left unchanged.
+ * - The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`.
+ * - The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first.
+ *
+ * @param x - input ndarray
+ * @param options - function options
+ * @returns output ndarray
+ *
+ * @example
+ * var array = require( '@stdlib/ndarray/array' );
+ *
+ * var x = array( [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ] );
+ * // returns [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ]
+ *
+ * var out = toSorted( x );
+ * // returns [ [ [ -5.0, -3.0 ] ], [ [ 1.0, 2.0 ] ], [ [ 4.0, 6.0 ] ] ]
+ */
+ ( x: T, options?: Options ): U; // NOTE: we lose type specificity here. We can likely address this with type maps
+
+ /**
+ * Returns a new ndarray containing the elements of an input ndarray sorted along one or more ndarray dimensions.
+ *
+ * ## Notes
+ *
+ * - If `sortOrder < 0.0` or is either `'desc'` or `'descending'`, the input ndarray is sorted in **decreasing** order. If `sortOrder > 0.0` or is either `'asc'` or `'ascending'`, the input ndarray is sorted in **increasing** order. If `sortOrder == 0.0`, the input ndarray is left unchanged.
+ * - The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`.
+ * - The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first.
+ *
+ * @param x - input ndarray
+ * @param sortOrder - sort order
+ * @param options - function options
+ * @returns output ndarray
+ *
+ * @example
+ * var array = require( '@stdlib/ndarray/array' );
+ *
+ * var x = array( [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ] );
+ * // returns [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ]
+ *
+ * var out = toSorted( x, 1.0 );
+ * // returns [ [ [ -5.0, -3.0 ] ], [ [ 1.0, 2.0 ] ], [ [ 4.0, 6.0 ] ] ]
+ */
+ ( x: T, sortOrder: SortOrder, options?: BaseOptions ): T;
+
+ /**
+ * Returns a new ndarray containing the elements of an input ndarray sorted along one or more ndarray dimensions.
+ *
+ * ## Notes
+ *
+ * - If `sortOrder < 0.0` or is either `'desc'` or `'descending'`, the input ndarray is sorted in **decreasing** order. If `sortOrder > 0.0` or is either `'asc'` or `'ascending'`, the input ndarray is sorted in **increasing** order. If `sortOrder == 0.0`, the input ndarray is left unchanged.
+ * - The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`.
+ * - The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first.
+ *
+ * @param x - input ndarray
+ * @param sortOrder - sort order
+ * @param options - function options
+ * @returns output ndarray
+ *
+ * @example
+ * var array = require( '@stdlib/ndarray/array' );
+ *
+ * var x = array( [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ] );
+ * // returns [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ]
+ *
+ * var out = toSorted( x, 1.0 );
+ * // returns [ [ [ -5.0, -3.0 ] ], [ [ 1.0, 2.0 ] ], [ [ 4.0, 6.0 ] ] ]
+ */
+ ( x: T, sortOrder: SortOrder, options?: Options ): U; // NOTE: we lose type specificity here. We can likely address this with type maps
+
+ /**
+ * Sorts the elements in an input ndarray along along one or more ndarray dimensions and assigns the results to an output ndarray.
+ *
+ * ## Notes
+ *
+ * - If `sortOrder < 0.0` or is either `'desc'` or `'descending'`, the input ndarray is sorted in **decreasing** order. If `sortOrder > 0.0` or is either `'asc'` or `'ascending'`, the input ndarray is sorted in **increasing** order. If `sortOrder == 0.0`, the input ndarray is left unchanged.
+ * - The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`.
+ * - The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first.
+ *
+ * @param x - input ndarray
+ * @param out - output ndarray
+ * @param options - function options
+ * @returns output ndarray
+ *
+ * @example
+ * var zeros = require( '@stdlib/ndarray/zeros' );
+ * var array = require( '@stdlib/ndarray/array' );
+ *
+ * var x = array( [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ] );
+ * // returns [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ]
+ *
+ * var y = zeros( [ 3, 1, 2 ] );
+ * // returns [ [ [ 0.0, 0.0 ] ], [ [ 0.0, 0.0 ] ], [ [ 0.0, 0.0 ] ] ]
+ *
+ * var out = toSorted.assign( x, y );
+ * // returns [ [ [ -5.0, -3.0 ] ], [ [ 1.0, 2.0 ] ], [ [ 4.0, 6.0 ] ] ]
+ *
+ * var bool = ( out === y );
+ * // returns true
+ */
+ assign( x: T, out: U, options?: BaseOptions ): U;
+
+ /**
+ * Sorts the elements in an input ndarray along along one or more ndarray dimensions and assigns the results to an output ndarray.
+ *
+ * ## Notes
+ *
+ * - If `sortOrder < 0.0` or is either `'desc'` or `'descending'`, the input ndarray is sorted in **decreasing** order. If `sortOrder > 0.0` or is either `'asc'` or `'ascending'`, the input ndarray is sorted in **increasing** order. If `sortOrder == 0.0`, the input ndarray is left unchanged.
+ * - The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`.
+ * - The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first.
+ *
+ * @param x - input ndarray
+ * @param sortOrder - sort order
+ * @param out - output ndarray
+ * @param options - function options
+ * @returns output ndarray
+ *
+ * @example
+ * var zeros = require( '@stdlib/ndarray/zeros' );
+ * var array = require( '@stdlib/ndarray/array' );
+ *
+ * var x = array( [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ] );
+ * // returns [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ]
+ *
+ * var y = zeros( [ 3, 1, 2 ] );
+ * // returns [ [ [ 0.0, 0.0 ] ], [ [ 0.0, 0.0 ] ], [ [ 0.0, 0.0 ] ] ]
+ *
+ * var out = toSorted.assign( x, 1, y );
+ * // returns [ [ [ -5.0, -3.0 ] ], [ [ 1.0, 2.0 ] ], [ [ 4.0, 6.0 ] ] ]
+ *
+ * var bool = ( out === y );
+ * // returns true
+ */
+ assign( x: T, sortOrder: SortOrder, out: U, options?: BaseOptions ): U;
+}
+
+/**
+* Returns a new ndarray with the elements of an input ndarray sorted along one or more ndarray dimensions.
+*
+* ## Notes
+*
+* - If `sortOrder < 0.0` or is either `'desc'` or `'descending'`, the input ndarray is sorted in **decreasing** order. If `sortOrder > 0.0` or is either `'asc'` or `'ascending'`, the input ndarray is sorted in **increasing** order. If `sortOrder == 0.0`, the input ndarray is left unchanged.
+* - The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`.
+* - The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first.
+*
+* @param x - input ndarray
+* @param sortOrder - sort order
+* @param options - function options
+* @returns output ndarray
+*
+* @example
+* var array = require( '@stdlib/ndarray/array' );
+*
+* var x = array( [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ] );
+* // returns [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ]
+*
+* var out = toSorted( x, 1.0 );
+* // returns [ [ [ -5.0, -3.0 ] ], [ [ 1.0, 2.0 ] ], [ [ 4.0, 6.0 ] ] ]
+*
+* @example
+* var zeros = require( '@stdlib/ndarray/zeros' );
+* var array = require( '@stdlib/ndarray/array' );
+*
+* var x = array( [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ] );
+* // returns [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ]
+*
+* var y = zeros( [ 3, 1, 2 ] );
+* // returns [ [ [ 0.0, 0.0 ] ], [ [ 0.0, 0.0 ] ], [ [ 0.0, 0.0 ] ] ]
+*
+* var out = toSorted.assign( x, y );
+* // returns [ [ [ -5.0, -3.0 ] ], [ [ 1.0, 2.0 ] ], [ [ 4.0, 6.0 ] ] ]
+*
+* var bool = ( out === y );
+* // returns true
+*/
+declare const toSorted: ToSorted;
+
+
+// EXPORTS //
+
+export = toSorted;
diff --git a/lib/node_modules/@stdlib/blas/ext/to-sorted/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/to-sorted/docs/types/test.ts
new file mode 100644
index 000000000000..387ef3220e8b
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sorted/docs/types/test.ts
@@ -0,0 +1,355 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/* eslint-disable space-in-parens */
+
+///
+
+import zeros = require( '@stdlib/ndarray/zeros' );
+import toSorted = require( './index' );
+
+
+// TESTS //
+
+// The function returns an ndarray...
+{
+ const x = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+
+ toSorted( x ); // $ExpectType float64ndarray
+ toSorted( x, 1.0 ); // $ExpectType float64ndarray
+ toSorted( x, {} ); // $ExpectType float64ndarray
+ toSorted( x, 1.0, {} ); // $ExpectType float64ndarray
+}
+
+// The compiler throws an error if the function is provided a first argument which is not an ndarray...
+{
+ toSorted( '5' ); // $ExpectError
+ toSorted( 5 ); // $ExpectError
+ toSorted( true ); // $ExpectError
+ toSorted( false ); // $ExpectError
+ toSorted( null ); // $ExpectError
+ toSorted( void 0 ); // $ExpectError
+ toSorted( {} ); // $ExpectError
+ toSorted( ( x: number ): number => x ); // $ExpectError
+
+ toSorted( '5', 1.0 ); // $ExpectError
+ toSorted( 5, 1.0 ); // $ExpectError
+ toSorted( true, 1.0 ); // $ExpectError
+ toSorted( false, 1.0 ); // $ExpectError
+ toSorted( null, 1.0 ); // $ExpectError
+ toSorted( void 0, 1.0 ); // $ExpectError
+ toSorted( {}, 1.0 ); // $ExpectError
+ toSorted( ( x: number ): number => x, 1.0 ); // $ExpectError
+
+ toSorted( '5', {} ); // $ExpectError
+ toSorted( 5, {} ); // $ExpectError
+ toSorted( true, {} ); // $ExpectError
+ toSorted( false, {} ); // $ExpectError
+ toSorted( null, {} ); // $ExpectError
+ toSorted( void 0, {} ); // $ExpectError
+ toSorted( {}, {} ); // $ExpectError
+ toSorted( ( x: number ): number => x, {} ); // $ExpectError
+
+ toSorted( '5', 1.0, {} ); // $ExpectError
+ toSorted( 5, 1.0, {} ); // $ExpectError
+ toSorted( true, 1.0, {} ); // $ExpectError
+ toSorted( false, 1.0, {} ); // $ExpectError
+ toSorted( null, 1.0, {} ); // $ExpectError
+ toSorted( void 0, 1.0, {} ); // $ExpectError
+ toSorted( {}, 1.0, {} ); // $ExpectError
+ toSorted( ( x: number ): number => x, 1.0, {} ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a sort order argument which is not an ndarray, supported string literal, or scalar value...
+{
+ const x = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+
+ toSorted( x, true ); // $ExpectError
+ toSorted( x, false ); // $ExpectError
+ toSorted( x, [] ); // $ExpectError
+ toSorted( x, ( x: number ): number => x ); // $ExpectError
+
+ toSorted( x, 'foo', {} ); // $ExpectError
+ toSorted( x, true, {} ); // $ExpectError
+ toSorted( x, false, {} ); // $ExpectError
+ toSorted( x, null, {} ); // $ExpectError
+ toSorted( x, void 0, {} ); // $ExpectError
+ toSorted( x, [], {} ); // $ExpectError
+ toSorted( x, {}, {} ); // $ExpectError
+ toSorted( x, ( x: number ): number => x, {} ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided an options argument which is not an object...
+{
+ const x = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+
+ toSorted( x, true ); // $ExpectError
+ toSorted( x, false ); // $ExpectError
+ toSorted( x, [] ); // $ExpectError
+ toSorted( x, ( x: number ): number => x ); // $ExpectError
+
+ toSorted( x, 1.0, '5' ); // $ExpectError
+ toSorted( x, 1.0, true ); // $ExpectError
+ toSorted( x, 1.0, false ); // $ExpectError
+ toSorted( x, 1.0, null ); // $ExpectError
+ toSorted( x, 1.0, [] ); // $ExpectError
+ toSorted( x, 1.0, ( x: number ): number => x ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided an invalid `dtype` option...
+{
+ const x = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+
+ toSorted( x, { 'dtype': '5' } ); // $ExpectError
+ toSorted( x, { 'dtype': 5 } ); // $ExpectError
+ toSorted( x, { 'dtype': true } ); // $ExpectError
+ toSorted( x, { 'dtype': false } ); // $ExpectError
+ toSorted( x, { 'dtype': null } ); // $ExpectError
+ toSorted( x, { 'dtype': [] } ); // $ExpectError
+ toSorted( x, { 'dtype': {} } ); // $ExpectError
+ toSorted( x, { 'dtype': ( x: number ): number => x } ); // $ExpectError
+
+ toSorted( x, 1.0, { 'dtype': '5' } ); // $ExpectError
+ toSorted( x, 1.0, { 'dtype': 5 } ); // $ExpectError
+ toSorted( x, 1.0, { 'dtype': true } ); // $ExpectError
+ toSorted( x, 1.0, { 'dtype': false } ); // $ExpectError
+ toSorted( x, 1.0, { 'dtype': null } ); // $ExpectError
+ toSorted( x, 1.0, { 'dtype': [] } ); // $ExpectError
+ toSorted( x, 1.0, { 'dtype': {} } ); // $ExpectError
+ toSorted( x, 1.0, { 'dtype': ( x: number ): number => x } ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided an invalid `dims` option...
+{
+ const x = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+
+ toSorted( x, { 'dims': '5' } ); // $ExpectError
+ toSorted( x, { 'dims': 5 } ); // $ExpectError
+ toSorted( x, { 'dims': true } ); // $ExpectError
+ toSorted( x, { 'dims': false } ); // $ExpectError
+ toSorted( x, { 'dims': null } ); // $ExpectError
+ toSorted( x, { 'dims': {} } ); // $ExpectError
+ toSorted( x, { 'dims': ( x: number ): number => x } ); // $ExpectError
+
+ toSorted( x, 1.0, { 'dims': '5' } ); // $ExpectError
+ toSorted( x, 1.0, { 'dims': 5 } ); // $ExpectError
+ toSorted( x, 1.0, { 'dims': true } ); // $ExpectError
+ toSorted( x, 1.0, { 'dims': false } ); // $ExpectError
+ toSorted( x, 1.0, { 'dims': null } ); // $ExpectError
+ toSorted( x, 1.0, { 'dims': {} } ); // $ExpectError
+ toSorted( x, 1.0, { 'dims': ( x: number ): number => x } ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided an unsupported number of arguments...
+{
+ const x = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+
+ toSorted(); // $ExpectError
+ toSorted( x, 10.0, {}, {} ); // $ExpectError
+}
+
+// Attached to the function is an `assign` method which returns an ndarray...
+{
+ const x = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+ const y = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+
+ toSorted.assign( x, y ); // $ExpectType float64ndarray
+ toSorted.assign( x, y, {} ); // $ExpectType float64ndarray
+ toSorted.assign( x, 1.0, y ); // $ExpectType float64ndarray
+ toSorted.assign( x, 1.0, y, {} ); // $ExpectType float64ndarray
+}
+
+// The compiler throws an error if the `assign` method is provided a first argument which is not an ndarray...
+{
+ const y = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+
+ toSorted.assign( '5', y ); // $ExpectError
+ toSorted.assign( 5, y ); // $ExpectError
+ toSorted.assign( true, y ); // $ExpectError
+ toSorted.assign( false, y ); // $ExpectError
+ toSorted.assign( null, y ); // $ExpectError
+ toSorted.assign( void 0, y ); // $ExpectError
+ toSorted.assign( {}, y ); // $ExpectError
+ toSorted.assign( ( x: number ): number => x, y ); // $ExpectError
+
+ toSorted.assign( '5', y, {} ); // $ExpectError
+ toSorted.assign( 5, y, {} ); // $ExpectError
+ toSorted.assign( true, y, {} ); // $ExpectError
+ toSorted.assign( false, y, {} ); // $ExpectError
+ toSorted.assign( null, y, {} ); // $ExpectError
+ toSorted.assign( void 0, y, {} ); // $ExpectError
+ toSorted.assign( {}, y, {} ); // $ExpectError
+ toSorted.assign( ( x: number ): number => x, y, {} ); // $ExpectError
+
+ toSorted.assign( '5', 1.0, y ); // $ExpectError
+ toSorted.assign( 5, 1.0, y ); // $ExpectError
+ toSorted.assign( true, 1.0, y ); // $ExpectError
+ toSorted.assign( false, 1.0, y ); // $ExpectError
+ toSorted.assign( null, 1.0, y ); // $ExpectError
+ toSorted.assign( void 0, 1.0, y ); // $ExpectError
+ toSorted.assign( {}, 1.0, y ); // $ExpectError
+ toSorted.assign( ( x: number ): number => x, 1.0, y ); // $ExpectError
+
+ toSorted.assign( '5', 1.0, y, {} ); // $ExpectError
+ toSorted.assign( 5, 1.0, y, {} ); // $ExpectError
+ toSorted.assign( true, 1.0, y, {} ); // $ExpectError
+ toSorted.assign( false, 1.0, y, {} ); // $ExpectError
+ toSorted.assign( null, 1.0, y, {} ); // $ExpectError
+ toSorted.assign( void 0, 1.0, y, {} ); // $ExpectError
+ toSorted.assign( {}, 1.0, y, {} ); // $ExpectError
+ toSorted.assign( ( x: number ): number => x, 1.0, y, {} ); // $ExpectError
+}
+
+// The compiler throws an error if the `assign` method is provided a sort order argument which is not an ndarray, supported string literal, or scalar value...
+{
+ const x = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+ const y = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+
+ toSorted.assign( x, true, y ); // $ExpectError
+ toSorted.assign( x, false, y ); // $ExpectError
+ toSorted.assign( x, [], y ); // $ExpectError
+ toSorted.assign( x, ( x: number ): number => x, y ); // $ExpectError
+
+ toSorted.assign( x, 'foo', y, {} ); // $ExpectError
+ toSorted.assign( x, true, y, {} ); // $ExpectError
+ toSorted.assign( x, false, y, {} ); // $ExpectError
+ toSorted.assign( x, null, y, {} ); // $ExpectError
+ toSorted.assign( x, void 0, y, {} ); // $ExpectError
+ toSorted.assign( x, [], y, {} ); // $ExpectError
+ toSorted.assign( x, ( x: number ): number => x, y, {} ); // $ExpectError
+}
+
+// The compiler throws an error if the `assign` method is provided an output argument which is not an ndarray...
+{
+ const x = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+
+ toSorted.assign( x, '5' ); // $ExpectError
+ toSorted.assign( x, 5 ); // $ExpectError
+ toSorted.assign( x, true ); // $ExpectError
+ toSorted.assign( x, false ); // $ExpectError
+ toSorted.assign( x, null ); // $ExpectError
+ toSorted.assign( x, void 0 ); // $ExpectError
+ toSorted.assign( x, {} ); // $ExpectError
+ toSorted.assign( x, ( x: number ): number => x ); // $ExpectError
+
+ toSorted.assign( x, 1.0, '5' ); // $ExpectError
+ toSorted.assign( x, 1.0, 5 ); // $ExpectError
+ toSorted.assign( x, 1.0, true ); // $ExpectError
+ toSorted.assign( x, 1.0, false ); // $ExpectError
+ toSorted.assign( x, 1.0, null ); // $ExpectError
+ toSorted.assign( x, 1.0, void 0 ); // $ExpectError
+ toSorted.assign( x, 1.0, {} ); // $ExpectError
+ toSorted.assign( x, 1.0, ( x: number ): number => x ); // $ExpectError
+
+ toSorted.assign( x, 1.0, '5', {} ); // $ExpectError
+ toSorted.assign( x, 1.0, 5, {} ); // $ExpectError
+ toSorted.assign( x, 1.0, true, {} ); // $ExpectError
+ toSorted.assign( x, 1.0, false, {} ); // $ExpectError
+ toSorted.assign( x, 1.0, null, {} ); // $ExpectError
+ toSorted.assign( x, 1.0, void 0, {} ); // $ExpectError
+ toSorted.assign( x, 1.0, {}, {} ); // $ExpectError
+ toSorted.assign( x, 1.0, ( x: number ): number => x, {} ); // $ExpectError
+}
+
+// The compiler throws an error if the `assign` method is provided an options argument which is not an object...
+{
+ const x = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+ const y = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+
+ toSorted.assign( x, y, '5' ); // $ExpectError
+ toSorted.assign( x, y, true ); // $ExpectError
+ toSorted.assign( x, y, false ); // $ExpectError
+ toSorted.assign( x, y, null ); // $ExpectError
+ toSorted.assign( x, y, [] ); // $ExpectError
+ toSorted.assign( x, y, ( x: number ): number => x ); // $ExpectError
+
+ toSorted.assign( x, 1.0, y, '5' ); // $ExpectError
+ toSorted.assign( x, 1.0, y, true ); // $ExpectError
+ toSorted.assign( x, 1.0, y, false ); // $ExpectError
+ toSorted.assign( x, 1.0, y, null ); // $ExpectError
+ toSorted.assign( x, 1.0, y, [] ); // $ExpectError
+ toSorted.assign( x, 1.0, y, ( x: number ): number => x ); // $ExpectError
+}
+
+// The compiler throws an error if the `assign` method is provided an invalid `dims` option...
+{
+ const x = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+ const y = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+
+ toSorted.assign( x, y, { 'dims': '5' } ); // $ExpectError
+ toSorted.assign( x, y, { 'dims': 5 } ); // $ExpectError
+ toSorted.assign( x, y, { 'dims': true } ); // $ExpectError
+ toSorted.assign( x, y, { 'dims': false } ); // $ExpectError
+ toSorted.assign( x, y, { 'dims': null } ); // $ExpectError
+ toSorted.assign( x, y, { 'dims': {} } ); // $ExpectError
+ toSorted.assign( x, y, { 'dims': ( x: number ): number => x } ); // $ExpectError
+
+ toSorted.assign( x, 1.0, y, { 'dims': '5' } ); // $ExpectError
+ toSorted.assign( x, 1.0, y, { 'dims': 5 } ); // $ExpectError
+ toSorted.assign( x, 1.0, y, { 'dims': true } ); // $ExpectError
+ toSorted.assign( x, 1.0, y, { 'dims': false } ); // $ExpectError
+ toSorted.assign( x, 1.0, y, { 'dims': null } ); // $ExpectError
+ toSorted.assign( x, 1.0, y, { 'dims': {} } ); // $ExpectError
+ toSorted.assign( x, 1.0, y, { 'dims': ( x: number ): number => x } ); // $ExpectError
+}
+
+// The compiler throws an error if the `assign` method is provided an unsupported number of arguments...
+{
+ const x = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+ const y = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+
+ toSorted.assign(); // $ExpectError
+ toSorted.assign( x ); // $ExpectError
+ toSorted.assign( x, 1.0, y, {}, {} ); // $ExpectError
+}
diff --git a/lib/node_modules/@stdlib/blas/ext/to-sorted/examples/index.js b/lib/node_modules/@stdlib/blas/ext/to-sorted/examples/index.js
new file mode 100644
index 000000000000..23641b1ea7a9
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sorted/examples/index.js
@@ -0,0 +1,37 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+var discreteUniform = require( '@stdlib/random/discrete-uniform' );
+var ndarray2array = require( '@stdlib/ndarray/to-array' );
+var toSorted = require( './../lib' );
+
+// Generate an ndarray of random numbers:
+var x = discreteUniform( [ 5, 5 ], -20, 20, {
+ 'dtype': 'generic'
+});
+console.log( ndarray2array( x ) );
+
+// Perform operation:
+var out = toSorted( x, {
+ 'dims': [ 0 ]
+});
+
+// Print the results:
+console.log( ndarray2array( out ) );
diff --git a/lib/node_modules/@stdlib/blas/ext/to-sorted/lib/assign.js b/lib/node_modules/@stdlib/blas/ext/to-sorted/lib/assign.js
new file mode 100644
index 000000000000..9f553b7ef369
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sorted/lib/assign.js
@@ -0,0 +1,165 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var isPlainObject = require( '@stdlib/assert/is-plain-object' );
+var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
+var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
+var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
+var isMostlySafeCast = require( '@stdlib/ndarray/base/assert/is-mostly-safe-data-type-cast' );
+var resolveStr = require( '@stdlib/ndarray/base/dtype-resolve-str' );
+var copy = require( '@stdlib/ndarray/base/assign' );
+var getDType = require( '@stdlib/ndarray/dtype' );
+var sort = require( '@stdlib/blas/ext/sort' );
+var format = require( '@stdlib/string/format' );
+
+
+// MAIN //
+
+/**
+* Sorts the elements of an input ndarray along one or more ndarray dimensions and assigns the results to an output ndarray.
+*
+* @param {ndarrayLike} x - input ndarray
+* @param {(ndarrayLike|number|string)} [sortOrder=1.0] - sort order
+* @param {ndarrayLike} out - output ndarray
+* @param {Options} [options] - function options
+* @param {IntegerArray} [options.dims] - list of dimensions over which to perform operation
+* @throws {TypeError} first argument must be an ndarray-like object
+* @throws {TypeError} sort order argument must be either an ndarray-like object, a numeric value, or a supported string
+* @throws {TypeError} output argument must be an ndarray-like object
+* @throws {TypeError} options argument must be an object
+* @throws {RangeError} dimension indices must not exceed input ndarray bounds
+* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions
+* @throws {TypeError} first argument cannot be safely cast to the data type of the output argument
+* @throws {Error} must provide valid options
+* @returns {ndarray} output ndarray
+*
+* @example
+* var zeros = require( '@stdlib/ndarray/zeros' );
+* var array = require( '@stdlib/ndarray/array' );
+*
+* var x = array( [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ] );
+* // returns [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ]
+*
+* var y = zeros( [ 3, 1, 2 ] );
+* // returns [ [ [ 0.0, 0.0 ] ], [ [ 0.0, 0.0 ] ], [ [ 0.0, 0.0 ] ] ]
+*
+* var out = assign( x, y );
+* // returns [ [ [ -5.0, -3.0 ] ], [ [ 1.0, 2.0 ] ], [ [ 4.0, 6.0 ] ] ]
+*
+* var bool = ( y === out );
+* // returns true
+*/
+function assign( x, sortOrder, out ) {
+ var hasOptions;
+ var options;
+ var nargs;
+ var xdt;
+ var odt;
+ var so;
+ var o;
+
+ nargs = arguments.length;
+ if ( !isndarrayLike( x ) ) {
+ throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );
+ }
+ // Initialize the sort order to ascending:
+ so = 1;
+
+ // Initialize a flag indicating whether an `options` argument was provided:
+ hasOptions = false;
+
+ // Case: assign( x, out )
+ if ( nargs <= 2 ) {
+ o = sortOrder;
+ if ( !isndarrayLike( o ) ) {
+ throw new TypeError( format( 'invalid argument. Second argument must be an ndarray-like object. Value: `%s`.', o ) );
+ }
+ }
+ // Case: assign( x, ???, ??? )
+ else if ( nargs === 3 ) {
+ // Case: assign( x, sort_order, out )
+ if ( isndarrayLike( out ) ) {
+ o = out;
+
+ // Case: assign( x, sort_order_scalar, out )
+ if ( isNumber( sortOrder ) || isString( sortOrder ) ) {
+ so = sortOrder;
+ }
+ // Case: assign( x, sort_order_ndarray, out )
+ else if ( isndarrayLike( sortOrder ) ) {
+ so = sortOrder;
+ }
+ // Case: assign( x, ???, out )
+ else {
+ throw new TypeError( format( 'invalid argument. Second argument must be either an ndarray-like object, a numeric value, or a supported string. Value: `%s`.', sortOrder ) );
+ }
+ }
+ // Case: assign( x, out, options )
+ else {
+ o = sortOrder;
+ if ( !isndarrayLike( o ) ) {
+ throw new TypeError( format( 'invalid argument. Second argument must be an ndarray-like object. Value: `%s`.', o ) );
+ }
+ options = out;
+ hasOptions = true;
+ }
+ }
+ // Case: assign( x, sort_order, out, options )
+ else { // nargs > 3
+ // Case: assign( x, sort_order_scalar, out, options )
+ if ( isNumber( sortOrder ) || isString( sortOrder ) ) {
+ so = sortOrder;
+ }
+ // Case: assign( x, sort_order_ndarray, out, options )
+ else if ( isndarrayLike( sortOrder ) ) {
+ so = sortOrder;
+ }
+ // Case: assign( x, ???, out, options )
+ else {
+ throw new TypeError( format( 'invalid argument. Second argument must be either an ndarray-like object, a numeric value, or a supported string. Value: `%s`.', sortOrder ) );
+ }
+ o = out;
+ if ( !isndarrayLike( o ) ) {
+ throw new TypeError( format( 'invalid argument. Third argument must be an ndarray-like object. Value: `%s`.', o ) );
+ }
+ options = arguments[ 3 ];
+ hasOptions = true;
+ }
+ if ( hasOptions && !isPlainObject( options ) ) {
+ throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
+ }
+ xdt = getDType( x );
+ odt = getDType( o );
+ if ( !isMostlySafeCast( xdt, odt ) ) {
+ throw new TypeError( format( 'invalid argument. First argument cannot be safely cast to the output data type. Data types: [%s, %s].', resolveStr( xdt ), resolveStr( odt ) ) );
+ }
+ copy( [ x, o ] );
+ if ( hasOptions ) {
+ return sort( o, so, options );
+ }
+ return sort( o, so );
+}
+
+
+// EXPORTS //
+
+module.exports = assign;
diff --git a/lib/node_modules/@stdlib/blas/ext/to-sorted/lib/index.js b/lib/node_modules/@stdlib/blas/ext/to-sorted/lib/index.js
new file mode 100644
index 000000000000..db099b286909
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sorted/lib/index.js
@@ -0,0 +1,70 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+/**
+* Return a new ndarray containing the elements of an input ndarray sorted along one or more ndarray dimensions.
+*
+* @module @stdlib/blas/ext/to-sorted
+*
+* @example
+* var array = require( '@stdlib/ndarray/array' );
+* var toSorted = require( '@stdlib/blas/ext/to-sorted' );
+*
+* var x = array( [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ] );
+* // returns [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ]
+*
+* var out = toSorted( x );
+* // returns [ [ [ -5.0, -3.0 ] ], [ [ 1.0, 2.0 ] ], [ [ 4.0, 6.0 ] ] ]
+*
+* @example
+* var zeros = require( '@stdlib/ndarray/zeros' );
+* var array = require( '@stdlib/ndarray/array' );
+* var toSorted = require( '@stdlib/blas/ext/to-sorted' );
+*
+* var x = array( [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ] );
+* // returns [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ]
+*
+* var y = zeros( [ 3, 1, 2 ] );
+* // returns [ [ [ 0.0, 0.0 ] ], [ [ 0.0, 0.0 ] ], [ [ 0.0, 0.0 ] ] ]
+*
+* var out = toSorted.assign( x, y );
+* // returns [ [ [ -5.0, -3.0 ] ], [ [ 1.0, 2.0 ] ], [ [ 4.0, 6.0 ] ] ]
+*
+* var bool = ( y === out );
+* // returns true
+*/
+
+// MODULES //
+
+var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
+var main = require( './main.js' );
+var assign = require( './assign.js' );
+
+
+// MAIN //
+
+setReadOnly( main, 'assign', assign );
+
+
+// EXPORTS //
+
+module.exports = main;
+
+// exports: { "assign": "main.assign" }
diff --git a/lib/node_modules/@stdlib/blas/ext/to-sorted/lib/main.js b/lib/node_modules/@stdlib/blas/ext/to-sorted/lib/main.js
new file mode 100644
index 000000000000..df4584ad182f
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sorted/lib/main.js
@@ -0,0 +1,132 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var hasOwnProp = require( '@stdlib/assert/has-own-property' );
+var isPlainObject = require( '@stdlib/assert/is-plain-object' );
+var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
+var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
+var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
+var isMostlySafeCast = require( '@stdlib/ndarray/base/assert/is-mostly-safe-data-type-cast' );
+var getDType = require( '@stdlib/ndarray/dtype' );
+var getShape = require( '@stdlib/ndarray/shape' );
+var getOrder = require( '@stdlib/ndarray/order' );
+var empty = require( '@stdlib/ndarray/empty' );
+var assign = require( '@stdlib/ndarray/base/assign' );
+var resolveStr = require( '@stdlib/ndarray/base/dtype-resolve-str' );
+var sort = require( '@stdlib/blas/ext/sort' );
+var format = require( '@stdlib/string/format' );
+
+
+// MAIN //
+
+/**
+* Returns a new ndarray containing the elements of an input ndarray sorted along one or more ndarray dimensions.
+*
+* @param {ndarrayLike} x - input ndarray
+* @param {(ndarrayLike|number|string)} [sortOrder=1.0] - sort order
+* @param {Options} [options] - function options
+* @param {IntegerArray} [options.dims] - list of dimensions over which to perform operation
+* @param {*} [options.dtype] - output ndarray data type
+* @throws {TypeError} first argument must be an ndarray-like object
+* @throws {TypeError} sort order argument must be either an ndarray-like object, a numeric value, or a supported string
+* @throws {TypeError} options argument must be an object
+* @throws {RangeError} dimension indices must not exceed input ndarray bounds
+* @throws {RangeError} number of dimension indices must not exceed the number of input ndarray dimensions
+* @throws {Error} must provide valid options
+* @returns {ndarray} output ndarray
+*
+* @example
+* var array = require( '@stdlib/ndarray/array' );
+*
+* var x = array( [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ] );
+* // returns [ [ [ 1.0, 2.0 ] ], [ [ -3.0, 4.0 ] ], [ [ -5.0, 6.0 ] ] ]
+*
+* var out = toSorted( x );
+* // returns [ [ [ -5.0, -3.0 ] ], [ [ 1.0, 2.0 ] ], [ [ 4.0, 6.0 ] ] ]
+*/
+function toSorted( x ) {
+ var sortOrder;
+ var options;
+ var nargs;
+ var xdt;
+ var ydt;
+ var y;
+ var o;
+
+ if ( !isndarrayLike( x ) ) {
+ throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );
+ }
+ nargs = arguments.length;
+ o = arguments[ 1 ];
+
+ // Case: toSorted( x )
+ if ( nargs < 2 ) {
+ sortOrder = 1;
+ }
+ // Case: toSorted( x, ??? )
+ else if ( nargs === 2 ) {
+ // Case: toSorted( x, sortOrder_string || sortOrder_scalar || sortOrder_ndarray ) )
+ if ( isString( o ) || isNumber( o ) || isndarrayLike( o ) ) {
+ sortOrder = o;
+ }
+ // Case: toSorted( x, options )
+ else {
+ sortOrder = 1;
+ options = o;
+ if ( !isPlainObject( options ) ) {
+ throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
+ }
+ }
+ }
+ // Case: toSorted( x, sortOrder, options )
+ else if ( nargs >= 3 ) {
+ sortOrder = o;
+ options = arguments[ 2 ];
+ if ( !isPlainObject( options ) ) {
+ throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
+ }
+ }
+ xdt = getDType( x );
+ if ( options && hasOwnProp( options, 'dtype' ) ) {
+ ydt = options.dtype;
+ if ( !isMostlySafeCast( xdt, ydt ) ) {
+ throw new TypeError( format( 'invalid argument. First argument cannot be safely cast to the output data type. Data types: [%s, %s].', resolveStr( xdt ), resolveStr( ydt ) ) );
+ }
+ } else {
+ ydt = xdt;
+ }
+ // Create an output ndarray:
+ y = empty( getShape( x ), {
+ 'dtype': ydt,
+ 'order': getOrder( x )
+ });
+
+ // Copy elements from the input ndarray to the output ndarray:
+ assign( [ x, y ] );
+
+ return sort( y, sortOrder, options || {} );
+}
+
+
+// EXPORTS //
+
+module.exports = toSorted;
diff --git a/lib/node_modules/@stdlib/blas/ext/to-sorted/package.json b/lib/node_modules/@stdlib/blas/ext/to-sorted/package.json
new file mode 100644
index 000000000000..82927b48c551
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sorted/package.json
@@ -0,0 +1,64 @@
+{
+ "name": "@stdlib/blas/ext/to-sorted",
+ "version": "0.0.0",
+ "description": "Return a new ndarray containing the elements of an input ndarray sorted along one or more ndarray dimensions.",
+ "license": "Apache-2.0",
+ "author": {
+ "name": "The Stdlib Authors",
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
+ },
+ "contributors": [
+ {
+ "name": "The Stdlib Authors",
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
+ }
+ ],
+ "main": "./lib",
+ "directories": {
+ "benchmark": "./benchmark",
+ "doc": "./docs",
+ "example": "./examples",
+ "lib": "./lib",
+ "test": "./test"
+ },
+ "types": "./docs/types",
+ "scripts": {},
+ "homepage": "https://github.com/stdlib-js/stdlib",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/stdlib-js/stdlib.git"
+ },
+ "bugs": {
+ "url": "https://github.com/stdlib-js/stdlib/issues"
+ },
+ "dependencies": {},
+ "devDependencies": {},
+ "engines": {
+ "node": ">=0.10.0",
+ "npm": ">2.7.0"
+ },
+ "os": [
+ "aix",
+ "darwin",
+ "freebsd",
+ "linux",
+ "macos",
+ "openbsd",
+ "sunos",
+ "win32",
+ "windows"
+ ],
+ "keywords": [
+ "stdlib",
+ "stdmath",
+ "statistics",
+ "stats",
+ "mathematics",
+ "math",
+ "arrange",
+ "sort",
+ "sorted",
+ "ndarray"
+ ],
+ "__stdlib__": {}
+}
diff --git a/lib/node_modules/@stdlib/blas/ext/to-sorted/test/test.assign.js b/lib/node_modules/@stdlib/blas/ext/to-sorted/test/test.assign.js
new file mode 100644
index 000000000000..27ac3271bf81
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sorted/test/test.assign.js
@@ -0,0 +1,1983 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var tape = require( 'tape' );
+var ndarray = require( '@stdlib/ndarray/ctor' );
+var zeros = require( '@stdlib/ndarray/zeros' );
+var empty = require( '@stdlib/ndarray/empty' );
+var ndarray2array = require( '@stdlib/ndarray/to-array' );
+var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
+var assign = require( './../lib/assign.js' );
+
+
+// TESTS //
+
+tape( 'main export is a function', function test( t ) {
+ t.ok( true, __filename );
+ t.strictEqual( typeof assign, 'function', 'main export is a function' );
+ t.end();
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( value, zeros( [ 2, 2 ] ) );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (sortOrder=scalar)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( value, 1.0, zeros( [ 2, 2 ] ) );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (sortOrder=ndarray)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( value, scalar2ndarray( 1.0 ), zeros( [ 2, 2 ] ) );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( value, zeros( [ 2, 2 ] ), {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (sortOrder=scalar, options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( value, 1.0, zeros( [ 2, 2 ] ), {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (sortOrder=ndarray, options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( value, scalar2ndarray( 1.0 ), zeros( [ 2, 2 ] ), {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which does not have a supported data type', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ empty( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( value, zeros( [ 2, 2 ] ) );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which does not have a supported data type (options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ empty( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( value, zeros( [ 2, 2 ] ), {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which does not have a supported data type (sortOrder=scalar)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ empty( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( value, 1.0, zeros( [ 2, 2 ] ) );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which does not have a supported data type (sortOrder=ndarray)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ empty( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( value, scalar2ndarray( 1.0 ), zeros( [ 2, 2 ] ) );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which does not have a supported data type (sortOrder=scalar, options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ empty( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( value, 1.0, zeros( [ 2, 2 ] ), {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which does not have a supported data type (sortOrder=ndarray, options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ empty( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( value, scalar2ndarray( 1.0 ), zeros( [ 2, 2 ] ), {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an output argument which is not an ndarray-like object', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( zeros( [ 2, 2 ] ), value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an output argument which is not an ndarray-like object (sortOrder=scalar)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( zeros( [ 2, 2 ] ), 1.0, value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an output argument which is not an ndarray-like object (sortOrder=ndarray)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( zeros( [ 2, 2 ] ), scalar2ndarray( 1.0 ), value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an output argument which is not an ndarray-like object (options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( zeros( [ 2, 2 ] ), value, {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an output argument which is not an ndarray-like object (sortOrder=scalar, options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( zeros( [ 2, 2 ] ), 1.0, value, {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an output argument which is not an ndarray-like object (sortOrder=ndarray, options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( zeros( [ 2, 2 ] ), scalar2ndarray( 1.0 ), value, {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an output argument which does not have a supported data type', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ empty( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( zeros( [ 2, 2 ] ), value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an output argument which does not have a supported data type (options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ empty( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( zeros( [ 2, 2 ] ), value, {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an output argument which does not have a supported data type (sortOrder=scalar)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ empty( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( zeros( [ 2, 2 ] ), 1.0, value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an output argument which does not have a supported data type (sortOrder=ndarray)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ empty( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( zeros( [ 2, 2 ] ), scalar2ndarray( 1.0 ), value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an output argument which does not have a supported data type (sortOrder=scalar, options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ empty( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( zeros( [ 2, 2 ] ), 1.0, value, {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an output argument which does not have a supported data type (sortOrder=ndarray, options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ empty( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( zeros( [ 2, 2 ] ), scalar2ndarray( 1.0 ), value, {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an output argument having a shape which is incompatible with the input ndarray', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ zeros( [ 2 ] ),
+ zeros( [ 2, 1 ] ),
+ zeros( [ 3, 3 ] ),
+ zeros( [ 2, 2, 2 ] ),
+ zeros( [ 2, 2, 2, 2 ] ),
+ zeros( [ 2, 2, 2, 2, 2 ] )
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( zeros( [ 2, 2 ] ), value );
+ };
+ }
+});
+
+tape( 'the function throws an error if the input ndarray cannot be safely cast to the output ndarray data type', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+
+ values = [
+ zeros( [ 2, 2 ], {
+ 'dtype': 'int8'
+ }),
+ zeros( [ 2, 2 ], {
+ 'dtype': 'int16'
+ }),
+ zeros( [ 2, 2 ], {
+ 'dtype': 'int32'
+ }),
+ zeros( [ 2, 2 ], {
+ 'dtype': 'uint8'
+ }),
+ zeros( [ 2, 2 ], {
+ 'dtype': 'uint8c'
+ }),
+ zeros( [ 2, 2 ], {
+ 'dtype': 'uint16'
+ }),
+ zeros( [ 2, 2 ], {
+ 'dtype': 'uint32'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided an output ndarray having dtype ' + values[ i ].dtype );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( x, value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `sortOrder` argument which is not an ndarray-like object, a numeric scalar, or a supported string', function test( t ) {
+ var values;
+ var x;
+ var y;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ 'invalid',
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( x, value, y );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `sortOrder` argument which is not an ndarray-like object, a numeric scalar, or a supported string (options)', function test( t ) {
+ var values;
+ var x;
+ var y;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ 'invalid',
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( x, value, y, {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `sortOrder` argument which is not broadcast-compatible', function test( t ) {
+ var values;
+ var opts;
+ var x;
+ var y;
+ var i;
+
+ opts = {
+ 'dtype': 'generic'
+ };
+ x = zeros( [ 2, 2 ], opts );
+
+ y = zeros( [ 2, 2 ], opts );
+
+ values = [
+ zeros( [ 4 ], opts ),
+ zeros( [ 2, 2, 2 ], opts ),
+ zeros( [ 0 ], opts )
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( x, value, y );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `sortOrder` argument which is not broadcast-compatible (options)', function test( t ) {
+ var values;
+ var opts;
+ var x;
+ var y;
+ var i;
+
+ opts = {
+ 'dtype': 'generic'
+ };
+ x = zeros( [ 2, 2 ], opts );
+
+ y = zeros( [ 2, 2 ], opts );
+
+ values = [
+ zeros( [ 4 ], opts ),
+ zeros( [ 2, 2, 2 ], opts ),
+ zeros( [ 0 ], opts )
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( x, value, y, {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an options argument which is not an object (sortOrder=scalar)', function test( t ) {
+ var values;
+ var x;
+ var y;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( x, 1.0, y, value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an options argument which is not an object (sortOrder=ndarray)', function test( t ) {
+ var values;
+ var opts;
+ var x;
+ var y;
+ var i;
+
+ opts = {
+ 'dtype': 'generic'
+ };
+ x = zeros( [ 2, 2 ], opts );
+
+ y = zeros( [ 2, 2 ], opts );
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( x, scalar2ndarray( 1.0, opts ), y, value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which is not an array-like object of integers', function test( t ) {
+ var values;
+ var x;
+ var y;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [ 'a' ],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( x, y, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which is not an array-like object of integers (sortOrder=scalar)', function test( t ) {
+ var values;
+ var x;
+ var y;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [ 'a' ],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( x, 1.0, y, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which is not an array-like object of integers (sortOrder=ndarray)', function test( t ) {
+ var values;
+ var opts;
+ var x;
+ var y;
+ var i;
+
+ opts = {
+ 'dtype': 'generic'
+ };
+ x = zeros( [ 2, 2 ], opts );
+
+ y = zeros( [ 2, 2 ], opts );
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [ 'a' ],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( x, scalar2ndarray( 1.0, opts ), y, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains out-of-bounds indices', function test( t ) {
+ var values;
+ var x;
+ var y;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ [ -10 ],
+ [ 0, 20 ],
+ [ 20 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( x, y, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains out-of-bounds indices (sortOrder=scalar)', function test( t ) {
+ var values;
+ var x;
+ var y;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ [ -10 ],
+ [ 0, 20 ],
+ [ 20 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( x, 1.0, y, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains out-of-bounds indices (sortOrder=ndarray)', function test( t ) {
+ var values;
+ var opts;
+ var x;
+ var y;
+ var i;
+
+ opts = {
+ 'dtype': 'generic'
+ };
+ x = zeros( [ 2, 2 ], opts );
+
+ y = zeros( [ 2, 2 ], opts );
+
+ values = [
+ [ -10 ],
+ [ 0, 20 ],
+ [ 20 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( x, scalar2ndarray( 1.0, opts ), y, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains too many indices', function test( t ) {
+ var values;
+ var x;
+ var y;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ [ 0, 1, 2 ],
+ [ 0, 1, 2, 3 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( x, y, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains too many indices (sortOrder=scalar)', function test( t ) {
+ var values;
+ var x;
+ var y;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ [ 0, 1, 2 ],
+ [ 0, 1, 2, 3 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( x, 1.0, y, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains too many indices (sortOrder=ndarray)', function test( t ) {
+ var values;
+ var opts;
+ var x;
+ var y;
+ var i;
+
+ opts = {
+ 'dtype': 'generic'
+ };
+ x = zeros( [ 2, 2 ], opts );
+
+ y = zeros( [ 2, 2 ], opts );
+
+ values = [
+ [ 0, 1, 2 ],
+ [ 0, 1, 2, 3 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( x, scalar2ndarray( 1.0, opts ), y, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains duplicate indices', function test( t ) {
+ var values;
+ var x;
+ var y;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ [ 0, 0 ],
+ [ 1, 1 ],
+ [ 0, 1, 0 ],
+ [ 1, 0, 1 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( x, y, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains duplicate indices (sortOrder=scalar)', function test( t ) {
+ var values;
+ var x;
+ var y;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ [ 0, 0 ],
+ [ 1, 1 ],
+ [ 0, 1, 0 ],
+ [ 1, 0, 1 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( x, 1.0, y, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains duplicate indices (sortOrder=ndarray)', function test( t ) {
+ var values;
+ var opts;
+ var x;
+ var y;
+ var i;
+
+ opts = {
+ 'dtype': 'generic'
+ };
+ x = zeros( [ 2, 2 ], opts );
+
+ y = zeros( [ 2, 2 ], opts );
+
+ values = [
+ [ 0, 0 ],
+ [ 1, 1 ],
+ [ 0, 1, 0 ],
+ [ 1, 0, 1 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ assign( x, scalar2ndarray( 1.0, opts ), y, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function sorts the input ndarray and assigns results to an output ndarray (default, row-major)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+ var y;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ actual = assign( x, y );
+ expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function sorts the input ndarray and assigns results to an output ndarray (default, column-major)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+ var y;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, y );
+ expected = [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function sorts the input ndarray and assigns results to an output ndarray (all dimensions, row-major)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+ var y;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ actual = assign( x, y, {
+ 'dims': [ 0, 1 ]
+ });
+ expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function sorts the input ndarray and assigns results to an output ndarray (all dimensions, column-major)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+ var y;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, y, {
+ 'dims': [ 0, 1 ]
+ });
+ expected = [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function sorts the input ndarray and assigns results to an output ndarray (no dimensions, row-major)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+ var y;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ actual = assign( x, y, {
+ 'dims': []
+ });
+ expected = [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function sorts the input ndarray and assigns results to an output ndarray (no dimensions, column-major)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+ var y;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, y, {
+ 'dims': []
+ });
+ expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports specifying operation dimensions (row-major)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+ var y;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ actual = assign( x, y, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = assign( x, y, {
+ 'dims': [ 1 ]
+ });
+ expected = [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports specifying operation dimensions (column-major)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+ var y;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, y, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+
+ actual = assign( x, y, {
+ 'dims': [ 1 ]
+ });
+ expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports providing a `sortOrder` argument (scalar)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+ var y;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'row-major'
+ });
+
+ actual = assign( x, 1.0, y );
+ expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, -1.0, y );
+ expected = [ [ 4.0, -1.0 ], [ 2.0, -3.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports providing a `sortOrder` argument (scalar, options)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+ var y;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'row-major'
+ });
+
+ actual = assign( x, 1.0, y, {} );
+ expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, -1.0, y, {} );
+ expected = [ [ 4.0, -1.0 ], [ 2.0, -3.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'row-major'
+ });
+
+ actual = assign( x, 0.0, y, {} );
+ expected = [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports providing a `sortOrder` argument (0d ndarray)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var opts;
+ var x;
+ var y;
+
+ opts = {
+ 'dtype': 'generic'
+ };
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'row-major'
+ });
+
+ actual = assign( x, scalar2ndarray( 1.0, opts ), y );
+ expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, scalar2ndarray( -1.0, opts ), y );
+ expected = [ [ 4.0, -1.0 ], [ 2.0, -3.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, scalar2ndarray( 0.0, opts ), y );
+ expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports providing a `sortOrder` argument (0d ndarray, options)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var opts;
+ var x;
+ var y;
+
+ opts = {
+ 'dtype': 'generic'
+ };
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'row-major'
+ });
+
+ actual = assign( x, scalar2ndarray( 1.0, opts ), y, {} );
+ expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, scalar2ndarray( -1.0, opts ), y, {} );
+ expected = [ [ 4.0, -1.0 ], [ 2.0, -3.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, scalar2ndarray( 0.0, opts ), y, {} );
+ expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports providing a `sortOrder` argument (scalar, broadcasted)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+ var y;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'row-major'
+ });
+
+ actual = assign( x, 1.0, y, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, -1.0, y, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ 2.0, 4.0 ], [ -1.0, -3.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, 0.0, y, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports providing a `sortOrder` argument (0d ndarray, broadcasted)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var opts;
+ var x;
+ var y;
+
+ opts = {
+ 'dtype': 'generic'
+ };
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'row-major'
+ });
+
+ actual = assign( x, scalar2ndarray( 1.0, opts ), y, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, scalar2ndarray( -1.0, opts ), y, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ 2.0, 4.0 ], [ -1.0, -3.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, scalar2ndarray( 0.0, opts ), y, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports providing a `sortOrder` argument (string literals)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+ var y;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ actual = assign( x, 'asc', y );
+ expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = assign( x, 'ascending', y );
+ expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = assign( x, 'desc', y );
+ expected = [ [ 4.0, 2.0 ], [ -1.0, -3.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = assign( x, 'descending', y );
+ expected = [ [ 4.0, 2.0 ], [ -1.0, -3.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports providing a `sortOrder` argument (string literals, options)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+ var y;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ actual = assign( x, 'asc', y, {} );
+ expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = assign( x, 'descending', y, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -1.0, 4.0 ], [ -3.0, 2.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports providing a `sortOrder` argument (ndarray)', function test( t ) {
+ var sortOrder;
+ var expected;
+ var actual;
+ var xbuf;
+ var obuf;
+ var opts;
+ var x;
+ var y;
+
+ opts = {
+ 'dtype': 'generic'
+ };
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ obuf = [ 1.0, -1.0 ];
+ sortOrder = new ndarray( opts.dtype, obuf, [ 2 ], [ 1 ], 0, 'row-major' );
+ actual = assign( x, sortOrder, y, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -3.0, 4.0 ], [ -1.0, 2.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ obuf = [ 1.0, -1.0 ];
+ sortOrder = new ndarray( opts.dtype, obuf, [ 2 ], [ 1 ], 0, 'row-major' );
+ actual = assign( x, sortOrder, y, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -1.0, 4.0 ], [ 2.0, -3.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ 1.0, -2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'row-major'
+ });
+
+ obuf = [ 0.0, -1.0 ];
+ sortOrder = new ndarray( opts.dtype, obuf, [ 2 ], [ 1 ], 0, 'row-major' );
+ actual = assign( x, sortOrder, y, {
+ 'dims': [ 1 ]
+ });
+ expected = [ [ 1.0, -2.0 ], [ 4.0, -3.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
diff --git a/lib/node_modules/@stdlib/blas/ext/to-sorted/test/test.js b/lib/node_modules/@stdlib/blas/ext/to-sorted/test/test.js
new file mode 100644
index 000000000000..3b0e889d18e6
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sorted/test/test.js
@@ -0,0 +1,39 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var tape = require( 'tape' );
+var isMethod = require( '@stdlib/assert/is-method' );
+var toSorted = require( './../lib' );
+
+
+// TESTS //
+
+tape( 'main export is a function', function test( t ) {
+ t.ok( true, __filename );
+ t.strictEqual( typeof toSorted, 'function', 'main export is a function' );
+ t.end();
+});
+
+tape( 'attached to the main export is an `assign` method', function test( t ) {
+ t.strictEqual( isMethod( toSorted, 'assign' ), true, 'returns expected value' );
+ t.end();
+});
diff --git a/lib/node_modules/@stdlib/blas/ext/to-sorted/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/to-sorted/test/test.main.js
new file mode 100644
index 000000000000..6f8e9aa027c7
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sorted/test/test.main.js
@@ -0,0 +1,1904 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var tape = require( 'tape' );
+var isEqualDataType = require( '@stdlib/ndarray/base/assert/is-equal-data-type' );
+var isSameArray = require( '@stdlib/assert/is-same-array' );
+var Float64Array = require( '@stdlib/array/float64' );
+var Float32Array = require( '@stdlib/array/float32' );
+var Int8Array = require( '@stdlib/array/int8' );
+var ndarray = require( '@stdlib/ndarray/ctor' );
+var zeros = require( '@stdlib/ndarray/zeros' );
+var empty = require( '@stdlib/ndarray/empty' );
+var ndarray2array = require( '@stdlib/ndarray/to-array' );
+var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
+var getDType = require( '@stdlib/ndarray/dtype' );
+var getShape = require( '@stdlib/ndarray/shape' );
+var getOrder = require( '@stdlib/ndarray/order' );
+var getData = require( '@stdlib/ndarray/data-buffer' );
+var toSorted = require( './../lib' );
+
+
+// TESTS //
+
+tape( 'main export is a function', function test( t ) {
+ t.ok( true, __filename );
+ t.strictEqual( typeof toSorted, 'function', 'main export is a function' );
+ t.end();
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (sortOrder=scalar)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( value, 1.0 );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (sortOrder=ndarray)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( value, scalar2ndarray( 1.0 ) );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( value, {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (sortOrder=scalar, options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( value, 1.0, {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (sortOrder=ndarray, options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( value, scalar2ndarray( 1.0 ), {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object having a supported data type', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ empty( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object having a supported data type (sortOrder=scalar)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ empty( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( value, 1.0 );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object having a supported data type (sortOrder=ndarray)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ empty( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( value, scalar2ndarray( 1.0 ) );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object having a supported data type (options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ empty( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( value, {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object having a supported data type (sortOrder=scalar, options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ empty( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( value, 1.0, {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object having a supported data type (sortOrder=ndarray, options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ empty( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( value, scalar2ndarray( 1.0 ), {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `sortOrder` argument which is not an ndarray-like object, a numeric scalar, or a supported string', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ 'invalid',
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `sortOrder` argument which is not an ndarray-like object, a numeric scalar, or a supported string (options)', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ 'invalid',
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, value, {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `sortOrder` argument which is not broadcast-compatible', function test( t ) {
+ var values;
+ var opts;
+ var x;
+ var i;
+
+ opts = {
+ 'dtype': 'generic'
+ };
+ x = zeros( [ 2, 2 ], opts );
+
+ values = [
+ zeros( [ 4 ], opts ),
+ zeros( [ 2, 2, 2 ], opts ),
+ zeros( [ 0 ], opts )
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `sortOrder` argument which is not broadcast-compatible (options)', function test( t ) {
+ var values;
+ var opts;
+ var x;
+ var i;
+
+ opts = {
+ 'dtype': 'generic'
+ };
+ x = zeros( [ 2, 2 ], opts );
+
+ values = [
+ zeros( [ 4 ], opts ),
+ zeros( [ 2, 2, 2 ], opts ),
+ zeros( [ 0 ], opts )
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, value, {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an options argument which is not an object', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ '5',
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an options argument which is not an object (sortOrder=scalar)', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, 1.0, value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an options argument which is not an object (sortOrder=ndarray)', function test( t ) {
+ var values;
+ var opts;
+ var x;
+ var i;
+
+ opts = {
+ 'dtype': 'generic'
+ };
+ x = zeros( [ 2, 2 ], opts );
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, scalar2ndarray( 1.0, opts ), value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which is not an array-like object of integers', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [ 'a' ],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which is not an array-like object of integers (sortOrder=scalar)', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [ 'a' ],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, 1.0, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which is not an array-like object of integers (sortOrder=ndarray)', function test( t ) {
+ var values;
+ var opts;
+ var x;
+ var i;
+
+ opts = {
+ 'dtype': 'generic'
+ };
+ x = zeros( [ 2, 2 ], opts );
+
+ values = [
+ '5',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [ 'a' ],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, scalar2ndarray( 1.0, opts ), {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains out-of-bounds indices', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ [ -10 ],
+ [ 0, 20 ],
+ [ 20 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains out-of-bounds indices (sortOrder=scalar)', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ [ -10 ],
+ [ 0, 20 ],
+ [ 20 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, 1.0, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains out-of-bounds indices (sortOrder=ndarray)', function test( t ) {
+ var values;
+ var opts;
+ var x;
+ var i;
+
+ opts = {
+ 'dtype': 'generic'
+ };
+ x = zeros( [ 2, 2 ], opts );
+
+ values = [
+ [ -10 ],
+ [ 0, 20 ],
+ [ 20 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, scalar2ndarray( 1.0, opts ), {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains too many indices', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ [ 0, 1, 2 ],
+ [ 0, 1, 2, 3 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains too many indices (sortOrder=scalar)', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ [ 0, 1, 2 ],
+ [ 0, 1, 2, 3 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, 1.0, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains too many indices (sortOrder=ndarray)', function test( t ) {
+ var values;
+ var opts;
+ var x;
+ var i;
+
+ opts = {
+ 'dtype': 'generic'
+ };
+ x = zeros( [ 2, 2 ], opts );
+
+ values = [
+ [ 0, 1, 2 ],
+ [ 0, 1, 2, 3 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, scalar2ndarray( 1.0, opts ), {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains duplicate indices', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ [ 0, 0 ],
+ [ 1, 1 ],
+ [ 0, 1, 0 ],
+ [ 1, 0, 1 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains duplicate indices (sortOrder=scalar)', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ [ 0, 0 ],
+ [ 1, 1 ],
+ [ 0, 1, 0 ],
+ [ 1, 0, 1 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, 1.0, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains duplicate indices (sortOrder=ndarray)', function test( t ) {
+ var values;
+ var opts;
+ var x;
+ var i;
+
+ opts = {
+ 'dtype': 'generic'
+ };
+ x = zeros( [ 2, 2 ], opts );
+
+ values = [
+ [ 0, 0 ],
+ [ 1, 1 ],
+ [ 0, 1, 0 ],
+ [ 1, 0, 1 ]
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), Error, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, scalar2ndarray( 1.0, opts ), {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an invalid `dtype` option', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ '5',
+ 'foo',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [ 'a' ],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, {
+ 'dtype': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an invalid `dtype` option (sortOrder=scalar)', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ '5',
+ 'foo',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [ 'a' ],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, 1.0, {
+ 'dtype': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an invalid `dtype` option (sortOrder=string)', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ '5',
+ 'foo',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [ 'a' ],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, 'asc', {
+ 'dtype': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an invalid `dtype` option (sortOrder=ndarray)', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ values = [
+ '5',
+ 'foo',
+ 5,
+ NaN,
+ true,
+ false,
+ null,
+ void 0,
+ [ 'a' ],
+ {},
+ function noop() {}
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, scalar2ndarray( 1.0 ), {
+ 'dtype': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if the input ndarray cannot be safely cast to the output data type', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+
+ values = [
+ 'int8',
+ 'int16',
+ 'int32',
+ 'uint8',
+ 'uint8c',
+ 'uint16',
+ 'uint32'
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, {
+ 'dtype': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if the input ndarray cannot be safely cast to the output data type (sortOrder=scalar)', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+
+ values = [
+ 'int8',
+ 'int16',
+ 'int32',
+ 'uint8',
+ 'uint8c',
+ 'uint16',
+ 'uint32'
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, 1.0, {
+ 'dtype': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if the input ndarray cannot be safely cast to the output data type (sortOrder=string)', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+
+ values = [
+ 'int8',
+ 'int16',
+ 'int32',
+ 'uint8',
+ 'uint8c',
+ 'uint16',
+ 'uint32'
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, 'asc', {
+ 'dtype': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if the input ndarray cannot be safely cast to the output data type (sortOrder=ndarray)', function test( t ) {
+ var values;
+ var x;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+
+ values = [
+ 'int8',
+ 'int16',
+ 'int32',
+ 'uint8',
+ 'uint8c',
+ 'uint16',
+ 'uint32'
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ toSorted( x, scalar2ndarray( 1.0 ), {
+ 'dtype': value
+ });
+ };
+ }
+});
+
+tape( 'the function returns a sorted ndarray (default, row-major)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = toSorted( x );
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function returns a sorted ndarray (default, column-major)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+
+ actual = toSorted( x );
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function returns a sorted ndarray (all dimensions, row-major)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = toSorted( x, {
+ 'dims': [ 0, 1 ]
+ });
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function returns a sorted ndarray (all dimensions, column-major)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+
+ actual = toSorted( x, {
+ 'dims': [ 0, 1 ]
+ });
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function returns a sorted ndarray (no dimensions, row-major)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = toSorted( x, {
+ 'dims': []
+ });
+ expected = [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function returns a sorted ndarray (no dimensions, column-major)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+
+ actual = toSorted( x, {
+ 'dims': []
+ });
+ expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports specifying operation dimensions (row-major)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = toSorted( x, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = toSorted( x, {
+ 'dims': [ 1 ]
+ });
+ expected = [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports specifying operation dimensions (column-major)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+
+ actual = toSorted( x, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+
+ actual = toSorted( x, {
+ 'dims': [ 1 ]
+ });
+ expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports providing a `sortOrder` argument (scalar)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = toSorted( x, 1.0 );
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' );
+
+ actual = toSorted( x, -1.0 );
+ expected = [ 4.0, 2.0, -1.0, -3.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports providing a `sortOrder` argument (scalar, options)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = toSorted( x, 1.0, {} );
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' );
+
+ actual = toSorted( x, -1.0, {} );
+ expected = [ 4.0, 2.0, -1.0, -3.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = toSorted( x, 0.0, {} );
+ expected = [ -1.0, 2.0, -3.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports providing a `sortOrder` argument (0d ndarray)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var opts;
+ var x;
+
+ opts = {
+ 'dtype': 'generic'
+ };
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = toSorted( x, scalar2ndarray( 1.0, opts ) );
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' );
+
+ actual = toSorted( x, scalar2ndarray( -1.0, opts ) );
+ expected = [ 4.0, 2.0, -1.0, -3.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+
+ actual = toSorted( x, scalar2ndarray( 0.0, opts ) );
+ expected = [ -1.0, 2.0, -3.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports providing a `sortOrder` argument (0d ndarray, options)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var opts;
+ var x;
+
+ opts = {
+ 'dtype': 'generic'
+ };
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = toSorted( x, scalar2ndarray( 1.0, opts ), {} );
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'column-major' );
+
+ actual = toSorted( x, scalar2ndarray( -1.0, opts ), {} );
+ expected = [ 4.0, 2.0, -1.0, -3.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+
+ actual = toSorted( x, scalar2ndarray( 0.0, opts ), {} );
+ expected = [ -1.0, 2.0, -3.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports providing a `sortOrder` argument (scalar, broadcasted)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = toSorted( x, 1.0, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+
+ actual = toSorted( x, -1.0, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ 2.0, 4.0 ], [ -1.0, -3.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+
+ actual = toSorted( x, 0.0, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports providing a `sortOrder` argument (0d ndarray, broadcasted)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var opts;
+ var x;
+
+ opts = {
+ 'dtype': 'generic'
+ };
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = toSorted( x, scalar2ndarray( 1.0, opts ), {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+
+ actual = toSorted( x, scalar2ndarray( -1.0, opts ), {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ 2.0, 4.0 ], [ -1.0, -3.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+
+ actual = toSorted( x, scalar2ndarray( 0.0, opts ), {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports providing a `sortOrder` argument (string literals)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = toSorted( x, 'asc' );
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = toSorted( x, 'ascending' );
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = toSorted( x, 'desc' );
+ expected = [ 4.0, 2.0, -1.0, -3.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = toSorted( x, 'descending' );
+ expected = [ 4.0, 2.0, -1.0, -3.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports providing a `sortOrder` argument (string literals, options)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = toSorted( x, 'asc', {} );
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.strictEqual( isSameArray( getData( actual ), expected ), true, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( 'generic', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = toSorted( x, 'descending', {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -1.0, 4.0 ], [ -3.0, 2.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports providing a `sortOrder` argument (ndarray)', function test( t ) {
+ var sortOrder;
+ var expected;
+ var actual;
+ var xbuf;
+ var obuf;
+ var opts;
+ var x;
+
+ opts = {
+ 'dtype': 'generic'
+ };
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ obuf = [ 1.0, -1.0 ];
+ sortOrder = new ndarray( opts.dtype, obuf, [ 2 ], [ 1 ], 0, 'row-major' );
+ actual = toSorted( x, sortOrder, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -3.0, 4.0 ], [ -1.0, 2.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ -1.0, 2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 1, 2 ], 0, 'column-major' );
+
+ obuf = [ 1.0, -1.0 ];
+ sortOrder = new ndarray( opts.dtype, obuf, [ 2 ], [ 1 ], 0, 'row-major' );
+ actual = toSorted( x, sortOrder, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -1.0, 4.0 ], [ 2.0, -3.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ xbuf = [ 1.0, -2.0, -3.0, 4.0 ];
+ x = new ndarray( opts.dtype, xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ obuf = [ 0.0, -1.0 ];
+ sortOrder = new ndarray( opts.dtype, obuf, [ 2 ], [ 1 ], 0, 'row-major' );
+ actual = toSorted( x, sortOrder, {
+ 'dims': [ 1 ]
+ });
+ expected = [ [ 1.0, -2.0 ], [ 4.0, -3.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), getDType( x ) ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports specifying an output data type', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+
+ xbuf = new Float32Array( [ -1.0, 2.0, -3.0, 4.0 ] );
+ x = new ndarray( 'float32', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = toSorted( x, {
+ 'dtype': 'float64'
+ });
+ expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), 'float64' ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports specifying an output data type (sortOrder=scalar)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+
+ xbuf = new Float64Array( [ -1.0, 2.0, -3.0, 4.0 ] );
+ x = new ndarray( 'float64', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = toSorted( x, 1.0, {
+ 'dtype': 'float32'
+ });
+ expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), 'float32' ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports specifying an output data type (sortOrder=string)', function test( t ) {
+ var expected;
+ var actual;
+ var xbuf;
+ var x;
+
+ xbuf = new Int8Array( [ -1, 2, -3, 4 ] );
+ x = new ndarray( 'int8', xbuf, [ 2, 2 ], [ 2, 1 ], 0, 'row-major' );
+
+ actual = toSorted( x, 'desc', {
+ 'dtype': 'int32'
+ });
+ expected = [ [ 4, 2 ], [ -1, -3 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( isEqualDataType( getDType( actual ), 'int32' ), true, 'returns expected value' );
+ t.deepEqual( getShape( actual ), getShape( x ), 'returns expected value' );
+ t.strictEqual( getOrder( actual ), getOrder( x ), 'returns expected value' );
+ t.deepEqual( ndarray2array( actual ), expected, 'returns expected value' );
+
+ t.end();
+});