diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/README.md b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/README.md
new file mode 100644
index 000000000000..c35758deb643
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/README.md
@@ -0,0 +1,227 @@
+
+
+# toSortedhp
+
+> 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 using heapsort.
+
+
+
+## Usage
+
+```javascript
+var toSortedhp = require( '@stdlib/blas/ext/to-sortedhp' );
+```
+
+#### toSortedhp( 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 using heapsort.
+
+```javascript
+var ndarray2array = require( '@stdlib/ndarray/to-array' );
+var array = require( '@stdlib/ndarray/array' );
+
+var x = array( [ -1.0, 2.0, -3.0 ] );
+
+var y = toSortedhp( x );
+// returns
+
+var arr = ndarray2array( y );
+// 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].
+
+By default, the function sorts elements in increasing order. To sort in a different order, provide a `sortOrder` argument.
+
+```javascript
+var ndarray2array = require( '@stdlib/ndarray/to-array' );
+var array = require( '@stdlib/ndarray/array' );
+
+var x = array( [ -1.0, 2.0, -3.0 ] );
+
+var y = toSortedhp( x, -1.0 );
+// returns
+
+var arr = ndarray2array( y );
+// 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 ndarray2array = require( '@stdlib/ndarray/to-array' );
+var array = require( '@stdlib/ndarray/array' );
+
+var x = array( [ -1.0, 2.0, -3.0 ] );
+
+// Sort in ascending order:
+var y = toSortedhp( x, 'asc' );
+// returns
+
+var arr = ndarray2array( y );
+// returns [ -3.0, -1.0, 2.0 ]
+
+// Sort in descending order:
+y = toSortedhp( x, 'descending' );
+// returns
+
+arr = ndarray2array( y );
+// 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 ndarray2array = require( '@stdlib/ndarray/to-array' );
+var array = require( '@stdlib/ndarray/array' );
+
+var x = array( [ -1.0, 2.0, -3.0, 4.0 ], {
+ 'shape': [ 2, 2 ],
+ 'order': 'row-major'
+});
+
+var v = ndarray2array( x );
+// returns [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ]
+
+var y = toSortedhp( x, {
+ 'dims': [ 0 ]
+});
+// returns
+
+v = ndarray2array( y );
+// returns [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ]
+```
+
+#### toSortedhp.assign( x, y\[, sortOrder]\[, options] )
+
+Sorts the elements of an input [ndarray][@stdlib/ndarray/ctor] along one or more [ndarray][@stdlib/ndarray/ctor] dimensions using heapsort and assigns the results to an output [ndarray][@stdlib/ndarray/ctor].
+
+```javascript
+var ndarray2array = require( '@stdlib/ndarray/to-array' );
+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 = toSortedhp.assign( x, y );
+// returns
+
+var arr = ndarray2array( out );
+// 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].
+- **y**: output [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].
+
+
+
+
+
+
+
+## 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 algorithm has space complexity `O(1)` and time complexity `O(N log2 N)`.
+- The algorithm is **unstable**, meaning that the algorithm may change the order of [ndarray][@stdlib/ndarray/ctor] elements which are equal or equivalent (e.g., `NaN` values).
+- 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/array/discrete-uniform' );
+var ndarray2array = require( '@stdlib/ndarray/to-array' );
+var ndarray = require( '@stdlib/ndarray/ctor' );
+var toSortedhp = require( '@stdlib/blas/ext/to-sortedhp' );
+
+// Generate an array of random numbers:
+var xbuf = discreteUniform( 25, -20, 20, {
+ 'dtype': 'generic'
+});
+
+// Wrap in an ndarray:
+var x = new ndarray( 'generic', xbuf, [ 5, 5 ], [ 5, 1 ], 0, 'row-major' );
+console.log( ndarray2array( x ) );
+
+// Perform operation:
+var out = toSortedhp( 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-sortedhp/benchmark/benchmark.assign.js b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/benchmark/benchmark.assign.js
new file mode 100644
index 000000000000..9b5dde5ebfb5
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/benchmark/benchmark.assign.js
@@ -0,0 +1,112 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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/array/uniform' );
+var ndarray = require( '@stdlib/ndarray/base/ctor' );
+var zeros = require( '@stdlib/ndarray/zeros' );
+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 );
+ x = new ndarray( options.dtype, x, [ len ], [ 1 ], 0, 'row-major' );
+ y = zeros( [ len ], {
+ 'dtype': options.dtype
+ });
+
+ 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, y, ( i%2 ) ? 1 : -1 );
+ 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( pkg+':dtype='+options.dtype+',len='+len, f );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/benchmark/benchmark.js
new file mode 100644
index 000000000000..cf5d13649599
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/benchmark/benchmark.js
@@ -0,0 +1,105 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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/array/uniform' );
+var ndarray = require( '@stdlib/ndarray/base/ctor' );
+var pkg = require( './../package.json' ).name;
+var toSortedhp = 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 );
+ x = new ndarray( options.dtype, x, [ len ], [ 1 ], 0, 'row-major' );
+
+ 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 = toSortedhp( 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( pkg+':dtype='+options.dtype+',len='+len, f );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/docs/repl.txt
new file mode 100644
index 000000000000..0e183aae8cc8
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/docs/repl.txt
@@ -0,0 +1,119 @@
+
+{{alias}}( x[, sortOrder][, options] )
+ Returns a new ndarray containing the elements of an input ndarray sorted
+ along one or more ndarray dimensions using heapsort.
+
+ 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 algorithm has space complexity O(1) and time complexity O(N log2 N).
+
+ The algorithm is *unstable*, meaning that the algorithm may change the order
+ of ndarray elements which are equal or equivalent (e.g., `NaN` values).
+
+ 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.
+
+ Returns
+ -------
+ out: ndarray
+ Output array.
+
+ Examples
+ --------
+ > var x = {{alias:@stdlib/ndarray/array}}( [ -1.0, 2.0, -3.0, -4.0 ] );
+ > var out = {{alias}}( x );
+ > {{alias:@stdlib/ndarray/to-array}}( out )
+ [ -4.0, -3.0, -1.0, 2.0 ]
+
+
+{{alias}}.assign( x, y[, sortOrder][, options] )
+ Sorts elements of an input ndarray along one or more ndarray dimensions
+ using heapsort and assigns the results to an output ndarray.
+
+ Parameters
+ ----------
+ x: ndarray
+ Input array. Must have a real-valued or "generic" data type.
+
+ y: ndarray
+ Output 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.
+
+ 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 );
+ > {{alias:@stdlib/ndarray/to-array}}( out )
+ [ -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-sortedhp/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/docs/types/index.d.ts
new file mode 100644
index 000000000000..e3606ba84a46
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/docs/types/index.d.ts
@@ -0,0 +1,240 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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 { 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 options.
+*/
+interface Options {
+ /**
+ * List of dimensions over which to perform operation.
+ */
+ dims?: ArrayLike;
+}
+
+/**
+* Interface for performing an operation on an ndarray.
+*/
+interface toSortedhp {
+ /**
+ * Returns a new ndarray containing the elements of an input ndarray sorted along one or more ndarray dimensions using heapsort.
+ *
+ * ## 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.
+ * - The algorithm has space complexity `O(1)` and time complexity `O(N log2 N)`.
+ * - The algorithm is **unstable**, meaning that the algorithm may change the order of ndarray elements which are equal or equivalent (e.g., `NaN` values).
+ *
+ * @param x - input ndarray
+ * @param options - function options
+ * @returns output ndarray
+ *
+ * @example
+ * var ndarray2array = require( '@stdlib/ndarray/to-array' );
+ * var array = require( '@stdlib/ndarray/array' );
+ *
+ * var x = array( [ -1.0, 2.0, -3.0 ] );
+ *
+ * var y = toSortedhp( x );
+ * // returns
+ *
+ * var arr = ndarray2array( y );
+ * // returns [ -3.0, -1.0, 2.0 ]
+ */
+ ( x: T, options?: Options ): U;
+
+ /**
+ * Returns a new ndarray containing the elements of an input ndarray sorted along one or more ndarray dimensions using heapsort.
+ *
+ * ## 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.
+ * - The algorithm has space complexity `O(1)` and time complexity `O(N log2 N)`.
+ * - The algorithm is **unstable**, meaning that the algorithm may change the order of ndarray elements which are equal or equivalent (e.g., `NaN` values).
+ *
+ * @param x - input ndarray
+ * @param sortOrder - sort order
+ * @param options - function options
+ * @returns output ndarray
+ *
+ * @example
+ * var ndarray2array = require( '@stdlib/ndarray/to-array' );
+ * var array = require( '@stdlib/ndarray/array' );
+ *
+ * var x = array( [ -1.0, 2.0, -3.0 ] );
+ *
+ * var y = toSortedhp( x, 1.0 );
+ * // returns
+ *
+ * var arr = ndarray2array( y );
+ * // returns [ -3.0, -1.0, 2.0 ]
+ */
+ ( x: T, sortOrder: SortOrder, options?: Options ): U;
+
+ /**
+ * Sorts the elements in an input ndarray along along one or more ndarray dimensions using heapsort 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.
+ * - The algorithm has space complexity `O(1)` and time complexity `O(N log2 N)`.
+ * - The algorithm is **unstable**, meaning that the algorithm may change the order of ndarray elements which are equal or equivalent (e.g., `NaN` values).
+ *
+ * @param x - input ndarray
+ * @param y - output ndarray
+ * @param options - function options
+ * @returns output ndarray
+ *
+ * @example
+ * var ndarray2array = require( '@stdlib/ndarray/to-array' );
+ * 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 = toSortedhp.assign( x, y );
+ * // returns
+ *
+ * var arr = ndarray2array( out );
+ * // returns [ -3.0, -1.0, 2.0 ]
+ *
+ * var bool = ( out === y );
+ * // returns true
+ */
+ assign( x: T, y: U, options?: Options ): U;
+
+ /**
+ * Sorts the elements in an input ndarray along along one or more ndarray dimensions using heapsort 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.
+ * - The algorithm has space complexity `O(1)` and time complexity `O(N log2 N)`.
+ * - The algorithm is **unstable**, meaning that the algorithm may change the order of ndarray elements which are equal or equivalent (e.g., `NaN` values).
+ *
+ * @param x - input ndarray
+ * @param y - output ndarray
+ * @param sortOrder - sort order
+ * @param options - function options
+ * @returns output ndarray
+ *
+ * @example
+ * var ndarray2array = require( '@stdlib/ndarray/to-array' );
+ * 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 = toSortedhp.assign( x, y, 1);
+ * // returns
+ *
+ * var arr = ndarray2array( out );
+ * // returns [ -3.0, -1.0, 2.0 ]
+ *
+ * var bool = ( out === y );
+ * // returns true
+ */
+ assign( x: T, y: U, sortOrder: SortOrder, options?: Options ): U;
+}
+
+/**
+* Returns a new ndarray with the elements of an input ndarray sorted along one or more ndarray dimensions using heapsort.
+*
+* ## 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.
+* - The algorithm has space complexity `O(1)` and time complexity `O(N log2 N)`.
+* - The algorithm is **unstable**, meaning that the algorithm may change the order of ndarray elements which are equal or equivalent (e.g., `NaN` values).
+*
+* @param x - input ndarray
+* @param sortOrder - sort order
+* @param options - function options
+* @returns output ndarray
+*
+* @example
+* var ndarray2array = require( '@stdlib/ndarray/to-array' );
+* var array = require( '@stdlib/ndarray/array' );
+*
+* var x = array( [ -1.0, 2.0, -3.0 ] );
+*
+* var y = toSortedhp( x, 1.0 );
+* // returns
+*
+* var arr = ndarray2array( y );
+* // returns [ -3.0, -1.0, 2.0 ]
+*
+* @example
+* var ndarray2array = require( '@stdlib/ndarray/to-array' );
+* 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 = toSortedhp.assign( x, y );
+* // returns
+*
+* var arr = ndarray2array( out );
+* // returns [ -3.0, -1.0, 2.0 ]
+*
+* var bool = ( out === y );
+* // returns true
+*/
+declare const toSortedhp: toSortedhp;
+
+
+// EXPORTS //
+
+export = toSortedhp;
diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/docs/types/test.ts
new file mode 100644
index 000000000000..e5e37a886eac
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/docs/types/test.ts
@@ -0,0 +1,338 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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 toSortedhp = require( './index' );
+
+
+// TESTS //
+
+// The function returns an ndarray...
+{
+ const x = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+
+ toSortedhp( x ); // $ExpectType OutputArray
+ toSortedhp( x, 1.0 ); // $ExpectType OutputArray
+ toSortedhp( x, {} ); // $ExpectType OutputArray
+ toSortedhp( x, 1.0, {} ); // $ExpectType OutputArray
+}
+
+// The compiler throws an error if the function is provided a first argument which is not an ndarray...
+{
+ toSortedhp( '5' ); // $ExpectError
+ toSortedhp( 5 ); // $ExpectError
+ toSortedhp( true ); // $ExpectError
+ toSortedhp( false ); // $ExpectError
+ toSortedhp( null ); // $ExpectError
+ toSortedhp( void 0 ); // $ExpectError
+ toSortedhp( {} ); // $ExpectError
+ toSortedhp( ( x: number ): number => x ); // $ExpectError
+
+ toSortedhp( '5', 1.0 ); // $ExpectError
+ toSortedhp( 5, 1.0 ); // $ExpectError
+ toSortedhp( true, 1.0 ); // $ExpectError
+ toSortedhp( false, 1.0 ); // $ExpectError
+ toSortedhp( null, 1.0 ); // $ExpectError
+ toSortedhp( void 0, 1.0 ); // $ExpectError
+ toSortedhp( {}, 1.0 ); // $ExpectError
+ toSortedhp( ( x: number ): number => x, 1.0 ); // $ExpectError
+
+ toSortedhp( '5', {} ); // $ExpectError
+ toSortedhp( 5, {} ); // $ExpectError
+ toSortedhp( true, {} ); // $ExpectError
+ toSortedhp( false, {} ); // $ExpectError
+ toSortedhp( null, {} ); // $ExpectError
+ toSortedhp( void 0, {} ); // $ExpectError
+ toSortedhp( {}, {} ); // $ExpectError
+ toSortedhp( ( x: number ): number => x, {} ); // $ExpectError
+
+ toSortedhp( '5', 1.0, {} ); // $ExpectError
+ toSortedhp( 5, 1.0, {} ); // $ExpectError
+ toSortedhp( true, 1.0, {} ); // $ExpectError
+ toSortedhp( false, 1.0, {} ); // $ExpectError
+ toSortedhp( null, 1.0, {} ); // $ExpectError
+ toSortedhp( void 0, 1.0, {} ); // $ExpectError
+ toSortedhp( {}, 1.0, {} ); // $ExpectError
+ toSortedhp( ( 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'
+ });
+
+ toSortedhp( x, true ); // $ExpectError
+ toSortedhp( x, false ); // $ExpectError
+ toSortedhp( x, [] ); // $ExpectError
+ toSortedhp( x, ( x: number ): number => x ); // $ExpectError
+
+ toSortedhp( x, 'foo', {} ); // $ExpectError
+ toSortedhp( x, true, {} ); // $ExpectError
+ toSortedhp( x, false, {} ); // $ExpectError
+ toSortedhp( x, null, {} ); // $ExpectError
+ toSortedhp( x, void 0, {} ); // $ExpectError
+ toSortedhp( x, [], {} ); // $ExpectError
+ toSortedhp( x, {}, {} ); // $ExpectError
+ toSortedhp( x, ( x: number ): number => x, {} ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a options argument which is not an object...
+{
+ const x = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+
+ toSortedhp( x, true ); // $ExpectError
+ toSortedhp( x, false ); // $ExpectError
+ toSortedhp( x, [] ); // $ExpectError
+ toSortedhp( x, ( x: number ): number => x ); // $ExpectError
+
+ toSortedhp( x, 1.0, '5' ); // $ExpectError
+ toSortedhp( x, 1.0, true ); // $ExpectError
+ toSortedhp( x, 1.0, false ); // $ExpectError
+ toSortedhp( x, 1.0, null ); // $ExpectError
+ toSortedhp( x, 1.0, [] ); // $ExpectError
+ toSortedhp( x, 1.0, ( 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'
+ });
+
+ toSortedhp( x, { 'dims': '5' } ); // $ExpectError
+ toSortedhp( x, { 'dims': 5 } ); // $ExpectError
+ toSortedhp( x, { 'dims': true } ); // $ExpectError
+ toSortedhp( x, { 'dims': false } ); // $ExpectError
+ toSortedhp( x, { 'dims': null } ); // $ExpectError
+ toSortedhp( x, { 'dims': {} } ); // $ExpectError
+ toSortedhp( x, { 'dims': ( x: number ): number => x } ); // $ExpectError
+
+ toSortedhp( x, 1.0, { 'dims': '5' } ); // $ExpectError
+ toSortedhp( x, 1.0, { 'dims': 5 } ); // $ExpectError
+ toSortedhp( x, 1.0, { 'dims': true } ); // $ExpectError
+ toSortedhp( x, 1.0, { 'dims': false } ); // $ExpectError
+ toSortedhp( x, 1.0, { 'dims': null } ); // $ExpectError
+ toSortedhp( x, 1.0, { 'dims': {} } ); // $ExpectError
+ toSortedhp( 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'
+ });
+
+ toSortedhp(); // $ExpectError
+ toSortedhp( 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'
+ });
+
+ toSortedhp.assign( x, y ); // $ExpectType float64ndarray
+ toSortedhp.assign( x, y, 1.0 ); // $ExpectType float64ndarray
+ toSortedhp.assign( x, y, {} ); // $ExpectType float64ndarray
+ toSortedhp.assign( x, y, 1.0, {} ); // $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'
+ });
+
+ toSortedhp.assign( '5', y ); // $ExpectError
+ toSortedhp.assign( 5, y ); // $ExpectError
+ toSortedhp.assign( true, y ); // $ExpectError
+ toSortedhp.assign( false, y ); // $ExpectError
+ toSortedhp.assign( null, y ); // $ExpectError
+ toSortedhp.assign( void 0, y ); // $ExpectError
+ toSortedhp.assign( {}, y ); // $ExpectError
+ toSortedhp.assign( ( x: number ): number => x, y ); // $ExpectError
+
+ toSortedhp.assign( '5', y, 1.0 ); // $ExpectError
+ toSortedhp.assign( 5, y, 1.0 ); // $ExpectError
+ toSortedhp.assign( true, y, 1.0 ); // $ExpectError
+ toSortedhp.assign( false, y, 1.0 ); // $ExpectError
+ toSortedhp.assign( null, y, 1.0 ); // $ExpectError
+ toSortedhp.assign( void 0, y, 1.0 ); // $ExpectError
+ toSortedhp.assign( {}, y, 1.0 ); // $ExpectError
+ toSortedhp.assign( ( x: number ): number => x, y, 1.0 ); // $ExpectError
+
+ toSortedhp.assign( '5', y, {} ); // $ExpectError
+ toSortedhp.assign( 5, y, {} ); // $ExpectError
+ toSortedhp.assign( true, y, {} ); // $ExpectError
+ toSortedhp.assign( false, y, {} ); // $ExpectError
+ toSortedhp.assign( null, y, {} ); // $ExpectError
+ toSortedhp.assign( void 0, y, {} ); // $ExpectError
+ toSortedhp.assign( {}, y, {} ); // $ExpectError
+ toSortedhp.assign( ( x: number ): number => x, y, {} ); // $ExpectError
+
+ toSortedhp.assign( '5', y, 1.0, {} ); // $ExpectError
+ toSortedhp.assign( 5, y, 1.0, {} ); // $ExpectError
+ toSortedhp.assign( true, y, 1.0, {} ); // $ExpectError
+ toSortedhp.assign( false, y, 1.0, {} ); // $ExpectError
+ toSortedhp.assign( null, y, 1.0, {} ); // $ExpectError
+ toSortedhp.assign( void 0, y, 1.0, {} ); // $ExpectError
+ toSortedhp.assign( {}, y, 1.0, {} ); // $ExpectError
+ toSortedhp.assign( ( x: number ): number => x, y, 1.0, {} ); // $ExpectError
+}
+
+// The compiler throws an error if the `assign` method is provided a second argument which is not an ndarray...
+{
+ const x = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+
+ toSortedhp.assign( x, '5' ); // $ExpectError
+ toSortedhp.assign( x, 5 ); // $ExpectError
+ toSortedhp.assign( x, true ); // $ExpectError
+ toSortedhp.assign( x, false ); // $ExpectError
+ toSortedhp.assign( x, null ); // $ExpectError
+ toSortedhp.assign( x, void 0 ); // $ExpectError
+ toSortedhp.assign( x, {} ); // $ExpectError
+ toSortedhp.assign( x, ( x: number ): number => x ); // $ExpectError
+
+ toSortedhp.assign( x, '5', 1.0 ); // $ExpectError
+ toSortedhp.assign( x, 5, 1.0 ); // $ExpectError
+ toSortedhp.assign( x, true, 1.0 ); // $ExpectError
+ toSortedhp.assign( x, false, 1.0 ); // $ExpectError
+ toSortedhp.assign( x, null, 1.0 ); // $ExpectError
+ toSortedhp.assign( x, void 0, 1.0 ); // $ExpectError
+ toSortedhp.assign( x, {}, 1.0 ); // $ExpectError
+ toSortedhp.assign( x, ( x: number ): number => x, 1.0 ); // $ExpectError
+
+ toSortedhp.assign( x, '5', {} ); // $ExpectError
+ toSortedhp.assign( x, 5, {} ); // $ExpectError
+ toSortedhp.assign( x, true, {} ); // $ExpectError
+ toSortedhp.assign( x, false, {} ); // $ExpectError
+ toSortedhp.assign( x, null, {} ); // $ExpectError
+ toSortedhp.assign( x, void 0, {} ); // $ExpectError
+ toSortedhp.assign( x, {}, {} ); // $ExpectError
+ toSortedhp.assign( x, ( x: number ): number => x, {} ); // $ExpectError
+
+ toSortedhp.assign( x, '5', 1.0, {} ); // $ExpectError
+ toSortedhp.assign( x, 5, 1.0, {} ); // $ExpectError
+ toSortedhp.assign( x, true, 1.0, {} ); // $ExpectError
+ toSortedhp.assign( x, false, 1.0, {} ); // $ExpectError
+ toSortedhp.assign( x, null, 1.0, {} ); // $ExpectError
+ toSortedhp.assign( x, void 0, 1.0, {} ); // $ExpectError
+ toSortedhp.assign( x, {}, 1.0, {} ); // $ExpectError
+ toSortedhp.assign( x, ( x: number ): number => x, 1.0, {} ); // $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'
+ });
+
+ toSortedhp.assign( x, y, true ); // $ExpectError
+ toSortedhp.assign( x, y, false ); // $ExpectError
+ toSortedhp.assign( x, y, [] ); // $ExpectError
+ toSortedhp.assign( x, y, ( x: number ): number => x ); // $ExpectError
+
+ toSortedhp.assign( x, y, 'foo', {} ); // $ExpectError
+ toSortedhp.assign( x, y, true, {} ); // $ExpectError
+ toSortedhp.assign( x, y, false, {} ); // $ExpectError
+ toSortedhp.assign( x, y, null, {} ); // $ExpectError
+ toSortedhp.assign( x, y, void 0, {} ); // $ExpectError
+ toSortedhp.assign( x, y, [], {} ); // $ExpectError
+ toSortedhp.assign( x, y, {}, {} ); // $ExpectError
+ toSortedhp.assign( x, y, ( x: number ): number => x, {} ); // $ExpectError
+}
+
+// The compiler throws an error if the `assign` method is provided a options argument which is not an object...
+{
+ const x = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+ const y = zeros( [ 2, 2 ], {
+ 'dtype': 'float64'
+ });
+
+ toSortedhp.assign( x, y, true ); // $ExpectError
+ toSortedhp.assign( x, y, false ); // $ExpectError
+ toSortedhp.assign( x, y, [] ); // $ExpectError
+ toSortedhp.assign( x, y, ( x: number ): number => x ); // $ExpectError
+
+ toSortedhp.assign( x, y, 1.0, '5' ); // $ExpectError
+ toSortedhp.assign( x, y, 1.0, true ); // $ExpectError
+ toSortedhp.assign( x, y, 1.0, false ); // $ExpectError
+ toSortedhp.assign( x, y, 1.0, null ); // $ExpectError
+ toSortedhp.assign( x, y, 1.0, [] ); // $ExpectError
+ toSortedhp.assign( x, y, 1.0, ( 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'
+ });
+
+ toSortedhp.assign( x, y, { 'dims': '5' } ); // $ExpectError
+ toSortedhp.assign( x, y, { 'dims': 5 } ); // $ExpectError
+ toSortedhp.assign( x, y, { 'dims': true } ); // $ExpectError
+ toSortedhp.assign( x, y, { 'dims': false } ); // $ExpectError
+ toSortedhp.assign( x, y, { 'dims': null } ); // $ExpectError
+ toSortedhp.assign( x, y, { 'dims': {} } ); // $ExpectError
+ toSortedhp.assign( x, y, { 'dims': ( x: number ): number => x } ); // $ExpectError
+
+ toSortedhp.assign( x, y, 1.0, { 'dims': '5' } ); // $ExpectError
+ toSortedhp.assign( x, y, 1.0, { 'dims': 5 } ); // $ExpectError
+ toSortedhp.assign( x, y, 1.0, { 'dims': true } ); // $ExpectError
+ toSortedhp.assign( x, y, 1.0, { 'dims': false } ); // $ExpectError
+ toSortedhp.assign( x, y, 1.0, { 'dims': null } ); // $ExpectError
+ toSortedhp.assign( x, y, 1.0, { 'dims': {} } ); // $ExpectError
+ toSortedhp.assign( x, y, 1.0, { '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'
+ });
+
+ toSortedhp.assign(); // $ExpectError
+ toSortedhp.assign( x ); // $ExpectError
+ toSortedhp.assign( x, y, 10.0, {}, {} ); // $ExpectError
+}
diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/examples/index.js b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/examples/index.js
new file mode 100644
index 000000000000..f43a4b7e26ca
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/examples/index.js
@@ -0,0 +1,41 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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/array/discrete-uniform' );
+var ndarray2array = require( '@stdlib/ndarray/to-array' );
+var ndarray = require( '@stdlib/ndarray/ctor' );
+var toSortedhp = require( './../lib' );
+
+// Generate an array of random numbers:
+var xbuf = discreteUniform( 25, -20, 20, {
+ 'dtype': 'generic'
+});
+
+// Wrap in an ndarray:
+var x = new ndarray( 'generic', xbuf, [ 5, 5 ], [ 5, 1 ], 0, 'row-major' );
+console.log( ndarray2array( x ) );
+
+// Perform operation:
+var out = toSortedhp( x, {
+ 'dims': [ 0 ]
+});
+
+// Print the results:
+console.log( ndarray2array( out ) );
diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/lib/assign.js b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/lib/assign.js
new file mode 100644
index 000000000000..83ed4d4774ee
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/lib/assign.js
@@ -0,0 +1,238 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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 isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
+var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
+var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
+var isRealFloatingDataType = require( '@stdlib/ndarray/base/assert/is-real-floating-point-data-type' );
+var isSignedIntegerDataType = require( '@stdlib/ndarray/base/assert/is-signed-integer-data-type' );
+var broadcastScalar = require( '@stdlib/ndarray/base/broadcast-scalar' );
+var maybeBroadcastArray = require( '@stdlib/ndarray/base/maybe-broadcast-array' );
+var getDType = require( '@stdlib/ndarray/dtype' );
+var getShape = require( '@stdlib/ndarray/shape' );
+var getOrder = require( '@stdlib/ndarray/order' );
+var format = require( '@stdlib/string/format' );
+var base = require( '@stdlib/ndarray/base/assign' );
+var sorthp = require( '@stdlib/blas/ext/sorthp' );
+var nonCoreShape = require( './non_core_shape.js' );
+
+
+// FUNCTIONS //
+
+/**
+* Returns a boolean indicating if a value is a string literal specifying ascending sort order.
+*
+* @private
+* @param {*} value - input value
+* @returns {boolean} boolean result
+*/
+function isAscending( value ) {
+ return ( value === 'asc' || value === 'ascending' );
+}
+
+/**
+* Returns a boolean indicating if a value is a string literal specifying descending sort order.
+*
+* @private
+* @param {*} value - input value
+* @returns {boolean} boolean result
+*/
+function isDescending( value ) {
+ return ( value === 'desc' || value === 'descending' );
+}
+
+/**
+* Converts a string literal to a numeric sort order value.
+*
+* @private
+* @param {string} value - input value
+* @throws {TypeError} must provide a supported string
+* @returns {number} sort order
+*/
+function string2order( value ) {
+ if ( isAscending( value ) ) {
+ return 1;
+ }
+ if ( isDescending( value ) ) {
+ return -1;
+ }
+ throw new TypeError( format( 'invalid argument. Second argument must be a valid sort order. Value: `%s`.', value ) );
+}
+
+/**
+* Normalize a numeric sort order value.
+*
+* ## Notes
+*
+* - Normalizing numeric sort order values to canonical values `-1`, `+1`, and `0` ensures that we can avoid truncation rounding errors when casting a provided sort order to the data type of the input ndarray.
+*
+* @private
+* @param {number} value - input value
+* @returns {number} normalized value
+*/
+function normalizeOrder( value ) {
+ if ( value < 0 ) {
+ return -1;
+ }
+ if ( value > 0 ) {
+ return 1;
+ }
+ return value;
+}
+
+
+// MAIN //
+
+/**
+* Sorts the elements of an input ndarray along one or more ndarray dimensions using heapsort and assigns the results to an output ndarray.
+*
+* @param {ndarrayLike} x - input ndarray
+* @param {ndarrayLike} y - output 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
+* @throws {TypeError} first argument must be an ndarray-like object
+* @throws {TypeError} second 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 Float64Array = require( '@stdlib/array/float64' );
+* var ndarray2array = require( '@stdlib/ndarray/to-array' );
+* var zeros = require( '@stdlib/ndarray/zeros' );
+* var ndarray = require( '@stdlib/ndarray/ctor' );
+*
+* // Create a data buffer:
+* var xbuf = new Float64Array( [ 1.0, 2.0, -3.0, 4.0, -5.0, 6.0 ] );
+*
+* // Define the shape of the input array:
+* var sh = [ 3, 1, 2 ];
+*
+* // Define the array strides:
+* var sx = [ 2, 2, 1 ];
+*
+* // Define the index offset:
+* var ox = 0;
+*
+* // Create an input ndarray:
+* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );
+*
+* // Create an output ndarray;
+* var y = zeros( sh );
+*
+* // Perform operation:
+* var out = assign( x, y );
+* // returns
+*
+* var arr = ndarray2array( out );
+* // returns [ [ [ -5.0, -3.0 ] ], [ [ 1.0, 2.0 ] ], [ [ 4.0, 6.0 ] ] ]
+*
+* var bool = ( y === out );
+* // returns true
+*/
+function assign( x, y ) {
+ var isStr;
+ var nargs;
+ var opts;
+ var ord;
+ var dt;
+ var sh;
+ var o;
+
+ if ( !isndarrayLike( x ) ) {
+ throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );
+ }
+ if ( !isndarrayLike( y ) ) {
+ throw new TypeError( format( 'invalid argument. Second argument must be an ndarray-like object. Value: `%s`.', y ) );
+ }
+ nargs = arguments.length;
+
+ // Assign elements from the input ndarray to the output ndarray:
+ base( [ x, y ] );
+
+ // Resolve output ndarray meta data:
+ dt = getDType( y );
+ if ( !isRealFloatingDataType( dt ) && !isSignedIntegerDataType( dt ) ) {
+ // Fallback to "generic" only if we cannot safely cast `-1` to the data type of the input ndarray:
+ dt = 'generic';
+ }
+ ord = getOrder( y );
+
+ // Case: toSortedhp( x, y )
+ if ( nargs < 3 ) {
+ return sorthp( y, broadcastScalar( 1, dt, [], ord ) );
+ }
+ o = arguments[ 2 ];
+
+ // Case: toSortedhp( x, y, ??? )
+ if ( nargs === 3 ) {
+ // Case: toSortedhp( x, y, sortOrder_scalar || sortOrder_string )
+ isStr = isString( o );
+ if ( isStr || isNumber( o ) ) {
+ return sorthp( y, broadcastScalar( ( isStr ) ? string2order( o ) : normalizeOrder( o ), dt, [], ord ) );
+ }
+ // Case: toSortedhp( x, y, sortOrder_ndarray )
+ if ( isndarrayLike( o ) ) {
+ // As the operation is performed across all dimensions, `o` is assumed to be a zero-dimensional ndarray...
+ return sorthp( y, o );
+ }
+ // Case: toSortedhp( x, y, opts )
+ opts = o;
+ o = 1;
+
+ // Intentionally fall through...
+ }
+ // Case: toSortedhp( x, y, sortOrder, opts )
+ else { // nargs > 2
+ opts = arguments[ 3 ];
+ }
+ // Case: toSortedhp( x, y, sortOrder_scalar || sortOrder_string, opts )
+ isStr = isString( o );
+ if ( isStr || isNumber( o ) ) {
+ if ( hasOwnProp( opts, 'dims' ) ) {
+ sh = nonCoreShape( getShape( y ), opts.dims );
+ } else {
+ sh = [];
+ }
+ o = broadcastScalar( ( isStr ) ? string2order( o ) : normalizeOrder( o ), dt, sh, getOrder( y ) );
+ }
+ // Case: toSortedhp( x, y, sortOrder_ndarray, opts )
+ else if ( isndarrayLike( o ) ) {
+ // When not provided `dims`, the operation is performed across all dimensions and `o` is assumed to be a zero-dimensional ndarray; when `dims` is provided, we need to broadcast `o` to match the shape of the non-core dimensions...
+ if ( hasOwnProp( opts, 'dims' ) ) {
+ o = maybeBroadcastArray( o, nonCoreShape( getShape( y ), opts.dims ) );
+ }
+ } else {
+ throw new TypeError( format( 'invalid argument. Second argument must be either an ndarray, a numeric scalar value, or a supported string. Value: `%s`.', o ) );
+ }
+ return sorthp( y, o, opts );
+}
+
+
+// EXPORTS //
+
+module.exports = assign;
diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/lib/index.js b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/lib/index.js
new file mode 100644
index 000000000000..2662601a5a6d
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/lib/index.js
@@ -0,0 +1,106 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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 using heapsort.
+*
+* @module @stdlib/blas/ext/to-sortedhp
+*
+* @example
+* var Float64Array = require( '@stdlib/array/float64' );
+* var ndarray = require( '@stdlib/ndarray/ctor' );
+* var ndarray2array = require( '@stdlib/ndarray/to-array' );
+* var toSortedhp = require( '@stdlib/blas/ext/to-sortedhp' );
+*
+* // Create a data buffer:
+* var xbuf = new Float64Array( [ 1.0, 2.0, -3.0, 4.0, -5.0, 6.0 ] );
+*
+* // Define the shape of the input array:
+* var sh = [ 3, 1, 2 ];
+*
+* // Define the array strides:
+* var sx = [ 2, 2, 1 ];
+*
+* // Define the index offset:
+* var ox = 0;
+*
+* // Create an input ndarray:
+* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );
+*
+* // Perform operation:
+* var out = toSortedhp( x );
+* // returns
+*
+* var arr = ndarray2array( out );
+* // returns [ [ [ -5.0, -3.0 ] ], [ [ 1.0, 2.0 ] ], [ [ 4.0, 6.0 ] ] ]
+*
+* @example
+* var Float64Array = require( '@stdlib/array/float64' );
+* var ndarray2array = require( '@stdlib/ndarray/to-array' );
+* var zeros = require( '@stdlib/ndarray/zeros' );
+* var ndarray = require( '@stdlib/ndarray/ctor' );
+* var toSortedhp = require( '@stdlib/blas/ext/to-sortedhp' );
+*
+* // Create a data buffer:
+* var xbuf = new Float64Array( [ 1.0, 2.0, -3.0, 4.0, -5.0, 6.0 ] );
+*
+* // Define the shape of the input array:
+* var sh = [ 3, 1, 2 ];
+*
+* // Define the array strides:
+* var sx = [ 2, 2, 1 ];
+*
+* // Define the index offset:
+* var ox = 0;
+*
+* // Create an input ndarray:
+* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );
+*
+* // Create an output ndarray;
+* var y = zeros( sh );
+*
+* // Perform operation:
+* var out = toSortedhp.assign( x, y );
+* // returns
+*
+* var arr = ndarray2array( out );
+* // 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-sortedhp/lib/main.js b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/lib/main.js
new file mode 100644
index 000000000000..77900961e456
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/lib/main.js
@@ -0,0 +1,231 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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 isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
+var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
+var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
+var isRealFloatingDataType = require( '@stdlib/ndarray/base/assert/is-real-floating-point-data-type' );
+var isSignedIntegerDataType = require( '@stdlib/ndarray/base/assert/is-signed-integer-data-type' );
+var broadcastScalar = require( '@stdlib/ndarray/base/broadcast-scalar' );
+var maybeBroadcastArray = require( '@stdlib/ndarray/base/maybe-broadcast-array' );
+var getDType = require( '@stdlib/ndarray/dtype' );
+var getShape = require( '@stdlib/ndarray/shape' );
+var getOrder = require( '@stdlib/ndarray/order' );
+var format = require( '@stdlib/string/format' );
+var emptyLike = require( '@stdlib/ndarray/empty-like' );
+var assign = require( '@stdlib/ndarray/base/assign' );
+var sorthp = require( '@stdlib/blas/ext/sorthp' );
+var nonCoreShape = require( './non_core_shape.js' );
+
+
+// FUNCTIONS //
+
+/**
+* Returns a boolean indicating if a value is a string literal specifying ascending sort order.
+*
+* @private
+* @param {*} value - input value
+* @returns {boolean} boolean result
+*/
+function isAscending( value ) {
+ return ( value === 'asc' || value === 'ascending' );
+}
+
+/**
+* Returns a boolean indicating if a value is a string literal specifying descending sort order.
+*
+* @private
+* @param {*} value - input value
+* @returns {boolean} boolean result
+*/
+function isDescending( value ) {
+ return ( value === 'desc' || value === 'descending' );
+}
+
+/**
+* Converts a string literal to a numeric sort order value.
+*
+* @private
+* @param {string} value - input value
+* @throws {TypeError} must provide a supported string
+* @returns {number} sort order
+*/
+function string2order( value ) {
+ if ( isAscending( value ) ) {
+ return 1;
+ }
+ if ( isDescending( value ) ) {
+ return -1;
+ }
+ throw new TypeError( format( 'invalid argument. Second argument must be a valid sort order. Value: `%s`.', value ) );
+}
+
+/**
+* Normalize a numeric sort order value.
+*
+* ## Notes
+*
+* - Normalizing numeric sort order values to canonical values `-1`, `+1`, and `0` ensures that we can avoid truncation rounding errors when casting a provided sort order to the data type of the input ndarray.
+*
+* @private
+* @param {number} value - input value
+* @returns {number} normalized value
+*/
+function normalizeOrder( value ) {
+ if ( value < 0 ) {
+ return -1;
+ }
+ if ( value > 0 ) {
+ return 1;
+ }
+ return value;
+}
+
+
+// MAIN //
+
+/**
+* Returns a new ndarray containing the elements of an input ndarray sorted along one or more ndarray dimensions using heapsort.
+*
+* @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
+* @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 Float64Array = require( '@stdlib/array/float64' );
+* var ndarray2array = require( '@stdlib/ndarray/to-array' );
+* var ndarray = require( '@stdlib/ndarray/ctor' );
+*
+* // Create a data buffer:
+* var xbuf = new Float64Array( [ 1.0, 2.0, -3.0, 4.0, -5.0, 6.0 ] );
+*
+* // Define the shape of the input array:
+* var sh = [ 3, 1, 2 ];
+*
+* // Define the array strides:
+* var sx = [ 2, 2, 1 ];
+*
+* // Define the index offset:
+* var ox = 0;
+*
+* // Create an input ndarray:
+* var x = new ndarray( 'float64', xbuf, sh, sx, ox, 'row-major' );
+*
+* // Perform operation:
+* var out = toSortedhp( x );
+* // returns
+*
+* var arr = ndarray2array( out );
+* // returns [ [ [ -5.0, -3.0 ] ], [ [ 1.0, 2.0 ] ], [ [ 4.0, 6.0 ] ] ]
+*/
+function toSortedhp( x ) {
+ var isStr;
+ var nargs;
+ var opts;
+ var ord;
+ var dt;
+ var sh;
+ var o;
+ var y;
+
+ if ( !isndarrayLike( x ) ) {
+ throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );
+ }
+ nargs = arguments.length;
+
+ // Create an output ndarray:
+ y = emptyLike( x );
+
+ // Assign elements from the input ndarray to the output ndarray:
+ assign( [ x, y ] );
+
+ // Resolve output ndarray meta data:
+ dt = getDType( y );
+ if ( !isRealFloatingDataType( dt ) && !isSignedIntegerDataType( dt ) ) {
+ // Fallback to "generic" only if we cannot safely cast `-1` to the data type of the input ndarray:
+ dt = 'generic';
+ }
+ ord = getOrder( y );
+
+ // Case: toSortedhp( x )
+ if ( nargs < 2 ) {
+ return sorthp( y, broadcastScalar( 1, dt, [], ord ) );
+ }
+ o = arguments[ 1 ];
+
+ // Case: toSortedhp( x, ??? )
+ if ( nargs === 2 ) {
+ // Case: toSortedhp( x, sortOrder_scalar || sortOrder_string )
+ isStr = isString( o );
+ if ( isStr || isNumber( o ) ) {
+ return sorthp( y, broadcastScalar( ( isStr ) ? string2order( o ) : normalizeOrder( o ), dt, [], ord ) );
+ }
+ // Case: toSortedhp( x, sortOrder_ndarray )
+ if ( isndarrayLike( o ) ) {
+ // As the operation is performed across all dimensions, `o` is assumed to be a zero-dimensional ndarray...
+ return sorthp( y, o );
+ }
+ // Case: toSortedhp( x, opts )
+ opts = o;
+ o = 1;
+
+ // Intentionally fall through...
+ }
+ // Case: toSortedhp( x, sortOrder, opts )
+ else { // nargs > 2
+ opts = arguments[ 2 ];
+ }
+ // Case: toSortedhp( x, sortOrder_scalar || sortOrder_string, opts )
+ isStr = isString( o );
+ if ( isStr || isNumber( o ) ) {
+ if ( hasOwnProp( opts, 'dims' ) ) {
+ sh = nonCoreShape( getShape( y ), opts.dims );
+ } else {
+ sh = [];
+ }
+ o = broadcastScalar( ( isStr ) ? string2order( o ) : normalizeOrder( o ), dt, sh, getOrder( y ) );
+ }
+ // Case: toSortedhp( x, sortOrder_ndarray, opts )
+ else if ( isndarrayLike( o ) ) {
+ // When not provided `dims`, the operation is performed across all dimensions and `o` is assumed to be a zero-dimensional ndarray; when `dims` is provided, we need to broadcast `o` to match the shape of the non-core dimensions...
+ if ( hasOwnProp( opts, 'dims' ) ) {
+ o = maybeBroadcastArray( o, nonCoreShape( getShape( y ), opts.dims ) );
+ }
+ } else {
+ throw new TypeError( format( 'invalid argument. Second argument must be either an ndarray, a numeric scalar value, or a supported string. Value: `%s`.', o ) );
+ }
+ return sorthp( y, o, opts );
+}
+
+
+// EXPORTS //
+
+module.exports = toSortedhp;
diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/lib/non_core_shape.js b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/lib/non_core_shape.js
new file mode 100644
index 000000000000..07e99731e89f
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/lib/non_core_shape.js
@@ -0,0 +1,50 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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 normalizeIndices = require( '@stdlib/ndarray/base/to-unique-normalized-indices' );
+var indicesComplement = require( '@stdlib/array/base/indices-complement' );
+var takeIndexed = require( '@stdlib/array/base/take-indexed' );
+
+
+// MAIN //
+
+/**
+* Returns the shape defined by the dimensions which are **not** included in a list of dimensions.
+*
+* @private
+* @param {NonNegativeIntegerArray} shape - input ndarray
+* @param {IntegerArray} dims - list of dimensions
+* @returns {NonNegativeIntegerArray} shape
+*/
+function nonCoreShape( shape, dims ) { // TODO: consider moving to a `@stdlib/ndarray/base` utility
+ var ind = normalizeIndices( dims, shape.length-1 );
+ if ( ind === null ) {
+ // Note: this is an error condition, as `null` is returned when provided out-of-bounds indices...
+ return [];
+ }
+ return takeIndexed( shape, indicesComplement( shape.length, ind ) );
+}
+
+
+// EXPORTS //
+
+module.exports = nonCoreShape;
diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/package.json b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/package.json
new file mode 100644
index 000000000000..e48d58696f8b
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/package.json
@@ -0,0 +1,64 @@
+{
+ "name": "@stdlib/blas/ext/to-sortedhp",
+ "version": "0.0.0",
+ "description": "Returns a new ndarray with the elements of an input ndarray sorted along one or more ndarray dimensions using heapsort.",
+ "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-sortedhp/test/test.assign.js b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/test/test.assign.js
new file mode 100644
index 000000000000..b6426c1dd5c7
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/test/test.assign.js
@@ -0,0 +1,2087 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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 isSameArray = require( '@stdlib/assert/is-same-array' );
+var ndarray = require( '@stdlib/ndarray/ctor' );
+var zeros = require( '@stdlib/ndarray/zeros' );
+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 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 (scalar sort order)', 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 ] ), 1.0 );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (ndarray sort order)', 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 ] ), 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() {
+ assign( value, zeros( [ 2, 2 ] ), {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (scalar sort order, 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 ] ), 1.0, {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (ndarray sort order, 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 ] ), scalar2ndarray( 1.0 ), {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided input and output ndarray-like objects does not have a supported data type', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ zeros( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ], values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( v1, v2 ) {
+ return function badValue() {
+ assign( v1, v2 );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided input and output ndarray-like objects does not have a supported data type (scalar sort order)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ zeros( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ], values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( v1, v2 ) {
+ return function badValue() {
+ assign( v1, v2, 1.0 );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided input and output ndarray-like objects does not have a supported data type (ndarray sort order)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ zeros( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ], values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( v1, v2 ) {
+ return function badValue() {
+ assign( v1, v2, scalar2ndarray( 1.0 ) );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided input and output ndarray-like objects does not have a supported data type (options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ zeros( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ], values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( v1, v2 ) {
+ return function badValue() {
+ assign( v1, v2, {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided input and output ndarray-like objects does not have a supported data type (scalar sort order, options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ zeros( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ], values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( v1, v2 ) {
+ return function badValue() {
+ assign( v1, v2, 1.0, {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided input and output ndarray-like objects does not have a supported data type (ndarray sort order, options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ zeros( [ 2, 2 ], {
+ 'dtype': 'bool'
+ })
+ ];
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[ i ], values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] );
+ }
+ t.end();
+
+ function badValue( v1, v2 ) {
+ return function badValue() {
+ assign( v1, v2, scalar2ndarray( 1.0 ), {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a second 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 a second argument which is not an ndarray-like object (scalar sort order)', 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, 1.0 );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a second argument which is not an ndarray-like object (ndarray sort order)', 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, scalar2ndarray( 1.0 ) );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a second 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 a second argument which is not an ndarray-like object (scalar sort order, 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, 1.0, {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a second argument which is not an ndarray-like object (ndarray sort order, 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, scalar2ndarray( 1.0 ), {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a second argument having dimensions greater than or less than the dimensions of 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 provided a second argument which is not an ndarray-like object having a supported data type', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ zeros( [ 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 a second argument which is not an ndarray-like object having a supported data type (scalar sort order)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ zeros( [ 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, 1.0 );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a second argument which is not an ndarray-like object having a supported data type (ndarray sort order)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ zeros( [ 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, scalar2ndarray( 1.0 ) );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a second argument which is not an ndarray-like object having a supported data type (options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ zeros( [ 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 a second argument which is not an ndarray-like object having a supported data type (scalar sort order, options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ zeros( [ 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, 1.0, {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a second argument which is not an ndarray-like object having a supported data type (ndarray sort order, options)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ zeros( [ 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, 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 support 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, y, value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `sortOrder` argument which is not an ndarray-like object, a numeric scalar, or a support 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, y, 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 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, y, 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 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, y, 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 y;
+ var i;
+
+ x = zeros( [ 2, 2 ], {
+ 'dtype': 'generic'
+ });
+
+ y = 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() {
+ assign( x, y, value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an options argument which is not an object (scalar sort order)', 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, y, 1.0, value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an options argument which is not an object (ndarray sort order)', 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, y, 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 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 (scalar sort order)', 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, 1.0, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which is not an array-like object of integers (ndarray sort order)', 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, y, 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 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 (scalar sort order)', 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, 1.0, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains out-of-bounds indices (ndarray sort order)', 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, y, 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 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 (scalar sort order)', 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, 1.0, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains too many indices (ndarray sort order)', 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, y, 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 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 (scalar sort order)', 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, 1.0, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains duplicate indices (ndarray sort order)', 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, y, scalar2ndarray( 1.0, opts ), {
+ '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.strictEqual( getDType( actual ), 'generic', '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 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, -1.0, 2.0, 4.0 ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 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.strictEqual( getDType( actual ), 'generic', '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 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, -1.0, 2.0, 4.0 ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 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.strictEqual( getDType( actual ), 'generic', '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 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.strictEqual( getDType( actual ), 'generic', '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;
+ 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.strictEqual( getDType( actual ), 'generic', '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 = assign( x, y, {
+ 'dims': [ 1 ]
+ });
+ expected = [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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;
+ 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.strictEqual( getDType( actual ), 'generic', '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 = assign( x, y, {
+ 'dims': [ 1 ]
+ });
+ expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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;
+ 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, y, 1.0 );
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, y, -1.0 );
+ expected = [ 4.0, 2.0, -1.0, -3.0 ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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;
+ 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, y, 1.0, {} );
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, y, -1.0, {} );
+ expected = [ 4.0, 2.0, -1.0, -3.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'row-major'
+ });
+
+ actual = assign( x, y, 0.0, {} );
+ expected = [ -1.0, 2.0, -3.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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;
+ 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, y, scalar2ndarray( 1.0, opts ) );
+ expected = [-3.0, -1.0, 2.0, 4.0 ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), opts.dtype, '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' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, y, scalar2ndarray( -1.0, opts ) );
+ expected = [ 4.0, 2.0, -1.0, -3.0 ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), opts.dtype, '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' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, y, scalar2ndarray( 0.0, opts ) );
+ expected = [ -1.0, 2.0, -3.0, 4.0 ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), opts.dtype, '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;
+ 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, y, scalar2ndarray( 1.0, opts ), {} );
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), opts.dtype, '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' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, y, scalar2ndarray( -1.0, opts ), {} );
+ expected = [ 4.0, 2.0, -1.0, -3.0 ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), opts.dtype, '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' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, y, scalar2ndarray( 0.0, opts ), {} );
+ expected = [ -1.0, 2.0, -3.0, 4.0 ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), opts.dtype, '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;
+ 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, y, 1.0, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, y, -1.0, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ 2.0, 4.0 ], [ -1.0, -3.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, y, 0.0, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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;
+ 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, y, scalar2ndarray( 1.0, opts ), {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), opts.dtype, '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' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, y, scalar2ndarray( -1.0, opts ), {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ 2.0, 4.0 ], [ -1.0, -3.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), opts.dtype, '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' );
+ y = zeros( [ 2, 2 ], {
+ 'dtype': 'generic',
+ 'order': 'column-major'
+ });
+
+ actual = assign( x, y, scalar2ndarray( 0.0, opts ), {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), opts.dtype, '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;
+ 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, 'asc' );
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 = assign( x, y, 'ascending' );
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 = assign( x, y, 'desc' );
+ expected = [ 4.0, 2.0, -1.0, -3.0 ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 = assign( x, y, 'descending' );
+ expected = [ 4.0, 2.0, -1.0, -3.0 ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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;
+ 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, 'asc', {} );
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 = assign( x, y, 'descending', {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -1.0, 4.0 ], [ -3.0, 2.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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;
+ 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, y, sortOrder, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -3.0, 4.0 ], [ -1.0, 2.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), opts.dtype, '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' );
+ 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, y, sortOrder, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -1.0, 4.0 ], [ 2.0, -3.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), opts.dtype, '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' );
+ 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, y, sortOrder, {
+ 'dims': [ 1 ]
+ });
+ expected = [ [ 1.0, -2.0 ], [ 4.0, -3.0 ] ];
+
+ t.strictEqual( actual, y, 'returns expected value' );
+ t.strictEqual( getDType( actual ), opts.dtype, '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();
+});
diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/test/test.js b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/test/test.js
new file mode 100644
index 000000000000..9246480f371a
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/test/test.js
@@ -0,0 +1,39 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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 toSortedhp = require( './../lib' );
+
+
+// TESTS //
+
+tape( 'main export is a function', function test( t ) {
+ t.ok( true, __filename );
+ t.strictEqual( typeof toSortedhp, 'function', 'main export is a function' );
+ t.end();
+});
+
+tape( 'attached to the main export is an `assign` method', function test( t ) {
+ t.strictEqual( isMethod( toSortedhp, 'assign' ), true, 'returns expected value' );
+ t.end();
+});
diff --git a/lib/node_modules/@stdlib/blas/ext/to-sortedhp/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/test/test.main.js
new file mode 100644
index 000000000000..8bc53f9bafee
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/to-sortedhp/test/test.main.js
@@ -0,0 +1,1559 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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 isSameArray = require( '@stdlib/assert/is-same-array' );
+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 toSortedhp = require( './../lib' );
+
+
+// TESTS //
+
+tape( 'main export is a function', function test( t ) {
+ t.ok( true, __filename );
+ t.strictEqual( typeof toSortedhp, '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() {
+ toSortedhp( value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (scalar sort order)', 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() {
+ toSortedhp( value, 1.0 );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (ndarray sort order)', 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() {
+ toSortedhp( 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() {
+ toSortedhp( value, {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (scalar sort order, 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() {
+ toSortedhp( value, 1.0, {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object (ndarray sort order, 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() {
+ toSortedhp( 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() {
+ toSortedhp( value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object having a supported data type (scalar sort order)', 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() {
+ toSortedhp( 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 (ndarray sort order)', 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() {
+ toSortedhp( 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() {
+ toSortedhp( value, {} );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a first argument which is not an ndarray-like object having a supported data type (scalar sort order, 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() {
+ toSortedhp( 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 (ndarray sort order, 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() {
+ toSortedhp( 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 support 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() {
+ toSortedhp( 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 support 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() {
+ toSortedhp( 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() {
+ toSortedhp( 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() {
+ toSortedhp( 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() {
+ toSortedhp( x, value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an options argument which is not an object (scalar sort order)', 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() {
+ toSortedhp( x, 1.0, value );
+ };
+ }
+});
+
+tape( 'the function throws an error if provided an options argument which is not an object (ndarray sort order)', 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() {
+ toSortedhp( 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() {
+ toSortedhp( x, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which is not an array-like object of integers (scalar sort order)', 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() {
+ toSortedhp( 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 (ndarray sort order)', 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() {
+ toSortedhp( 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() {
+ toSortedhp( x, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains out-of-bounds indices (scalar sort order)', 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() {
+ toSortedhp( x, 1.0, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains out-of-bounds indices (ndarray sort order)', 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() {
+ toSortedhp( 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() {
+ toSortedhp( x, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains too many indices (scalar sort order)', 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() {
+ toSortedhp( x, 1.0, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains too many indices (ndarray sort order)', 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() {
+ toSortedhp( 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() {
+ toSortedhp( x, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains duplicate indices (scalar sort order)', 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() {
+ toSortedhp( x, 1.0, {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function throws an error if provided a `dims` option which contains duplicate indices (ndarray sort order)', 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() {
+ toSortedhp( x, scalar2ndarray( 1.0, opts ), {
+ 'dims': value
+ });
+ };
+ }
+});
+
+tape( 'the function returns a sorted output 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 = toSortedhp( x );
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 output 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 = toSortedhp( x );
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 output 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 = toSortedhp( x, {
+ 'dims': [ 0, 1 ]
+ });
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 output 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 = toSortedhp( x, {
+ 'dims': [ 0, 1 ]
+ });
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 output 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 = toSortedhp( x, {
+ 'dims': []
+ });
+ expected = [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 output 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 = toSortedhp( x, {
+ 'dims': []
+ });
+ expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 = toSortedhp( x, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 = toSortedhp( x, {
+ 'dims': [ 1 ]
+ });
+ expected = [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 = toSortedhp( x, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 = toSortedhp( x, {
+ 'dims': [ 1 ]
+ });
+ expected = [ [ -3.0, -1.0 ], [ 2.0, 4.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 = toSortedhp( x, 1.0 );
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 = toSortedhp( x, -1.0 );
+ expected = [ 4.0, 2.0, -1.0, -3.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 = toSortedhp( x, 1.0, {} );
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 = toSortedhp( x, -1.0, {} );
+ expected = [ 4.0, 2.0, -1.0, -3.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 = toSortedhp( x, 0.0, {} );
+ expected = [ -1.0, 2.0, -3.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 = toSortedhp( x, scalar2ndarray( 1.0, opts ) );
+ expected = [-3.0, -1.0, 2.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), opts.dtype, '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 = toSortedhp( x, scalar2ndarray( -1.0, opts ) );
+ expected = [ 4.0, 2.0, -1.0, -3.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), opts.dtype, '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 = toSortedhp( x, scalar2ndarray( 0.0, opts ) );
+ expected = [ -1.0, 2.0, -3.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), opts.dtype, '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 = toSortedhp( x, scalar2ndarray( 1.0, opts ), {} );
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), opts.dtype, '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 = toSortedhp( x, scalar2ndarray( -1.0, opts ), {} );
+ expected = [ 4.0, 2.0, -1.0, -3.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), opts.dtype, '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 = toSortedhp( x, scalar2ndarray( 0.0, opts ), {} );
+ expected = [ -1.0, 2.0, -3.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), opts.dtype, '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 = toSortedhp( x, 1.0, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -3.0, 2.0 ], [ -1.0, 4.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 = toSortedhp( x, -1.0, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ 2.0, 4.0 ], [ -1.0, -3.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 = toSortedhp( x, 0.0, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -1.0, -3.0 ], [ 2.0, 4.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 = toSortedhp( 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( getDType( actual ), opts.dtype, '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 = toSortedhp( 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( getDType( actual ), opts.dtype, '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 = toSortedhp( 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( getDType( actual ), opts.dtype, '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 = toSortedhp( x, 'asc' );
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 = toSortedhp( x, 'ascending' );
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 = toSortedhp( x, 'desc' );
+ expected = [ 4.0, 2.0, -1.0, -3.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 = toSortedhp( x, 'descending' );
+ expected = [ 4.0, 2.0, -1.0, -3.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 = toSortedhp( x, 'asc', {} );
+ expected = [ -3.0, -1.0, 2.0, 4.0 ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 = toSortedhp( x, 'descending', {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -1.0, 4.0 ], [ -3.0, 2.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), 'generic', '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 = toSortedhp( x, sortOrder, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -3.0, 4.0 ], [ -1.0, 2.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), opts.dtype, '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 = toSortedhp( x, sortOrder, {
+ 'dims': [ 0 ]
+ });
+ expected = [ [ -1.0, 4.0 ], [ 2.0, -3.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), opts.dtype, '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 = toSortedhp( x, sortOrder, {
+ 'dims': [ 1 ]
+ });
+ expected = [ [ 1.0, -2.0 ], [ 4.0, -3.0 ] ];
+
+ t.notEqual( actual, x, 'returns expected value' );
+ t.strictEqual( getDType( actual ), opts.dtype, '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();
+});