diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/README.md b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/README.md
new file mode 100644
index 000000000000..4aaf013d3ea2
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/README.md
@@ -0,0 +1,266 @@
+
+
+# gsorthpBy
+
+> Sort a strided array using heapsort according to a provided callback function.
+
+
+
+## Usage
+
+```javascript
+var gsorthpBy = require( '@stdlib/blas/ext/base/gsorthp-by' );
+```
+
+#### gsorthpBy( N, x, strideX, clbk\[, thisArg] )
+
+Sorts a strided array using heapsort according to a provided callback function.
+
+```javascript
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+var x = [ 1.0, -2.0, 3.0, -4.0 ];
+
+gsorthpBy( x.length, x, 1, clbk );
+// x => [ -4.0, -2.0, 1.0, 3.0 ]
+```
+
+The function has the following parameters:
+
+- **N**: number of indexed elements.
+- **x**: input [`Array`][mdn-array] or [`typed array`][mdn-typed-array].
+- **strideX**: stride length.
+- **clbk**: callback function. The function should compare two values `a` and `b` and return a negative value if `a` should come before `b`, a positive value if `a` should come after `b`, and zero if `a` and `b` are equivalent.
+- **thisArg**: callback execution context (_optional_).
+
+To set the callback execution context, provide a `thisArg`.
+
+```javascript
+function clbk( a, b ) {
+ this.count += 1;
+ if ( a > b ) {
+ return -1;
+ }
+ if ( a < b ) {
+ return 1;
+ }
+ return 0;
+}
+
+var context = {
+ 'count': 0
+};
+
+var x = [ 10.0, -1.0, 3.0, 50.0 ];
+
+gsorthpBy( x.length, x, 1, clbk, context );
+// x => [ 50.0, 10.0, 3.0, -1.0 ]
+
+var cnt = context.count;
+// returns 7
+```
+
+The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to sort every other element:
+
+```javascript
+function clbk( a, b ) {
+ if ( a > b ) {
+ return -1;
+ }
+ if ( a < b ) {
+ return 1;
+ }
+ return 0;
+}
+
+var x = [ 1.0, -2.0, 3.0, -4.0 ];
+
+gsorthpBy( 2, x, 2, clbk );
+// x => [ 3.0, -2.0, 1.0, -4.0 ]
+```
+
+Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
+
+```javascript
+var Float64Array = require( '@stdlib/array/float64' );
+
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+var x0 = new Float64Array( [ 1.0, -2.0, 3.0, -4.0 ] );
+var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
+
+gsorthpBy( 2, x1, 2, clbk );
+// x0 => [ 1.0, -4.0, 3.0, -2.0 ]
+```
+
+#### gsorthpBy.ndarray( N, x, strideX, offsetX, clbk\[, thisArg] )
+
+Sorts a strided array using heapsort according to a provided callback function and using alternative indexing semantics.
+
+```javascript
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+var x = [ 1.0, -2.0, 3.0, -4.0 ];
+
+gsorthpBy.ndarray( x.length, x, 1, 0, clbk );
+// x => [ -4.0, -2.0, 1.0, 3.0 ]
+```
+
+The function has the following additional parameters:
+
+- **offsetX**: starting index.
+
+While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to access only the last three elements:
+
+```javascript
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+var x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ];
+
+gsorthpBy.ndarray( 3, x, 1, x.length-3, clbk );
+// x => [ 1.0, -2.0, 3.0, -6.0, -4.0, 5.0 ]
+```
+
+
+
+
+
+
+
+## Notes
+
+- If `N <= 0`, both functions return `x` unchanged.
+- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor]).
+- 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 strided array elements which are equal or equivalent.
+- The input strided array is sorted **in-place** (i.e., the input strided array is **mutated**).
+
+
+
+
+
+
+
+## Examples
+
+
+
+```javascript
+var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
+var gsorthpBy = require( '@stdlib/blas/ext/base/gsorthp-by' );
+
+function clbk( a, b ) {
+ if ( a > b ) {
+ return -1;
+ }
+ if ( a < b ) {
+ return 1;
+ }
+ return 0;
+}
+
+var x = discreteUniform( 10, -100, 100, {
+ 'dtype': 'float64'
+});
+console.log( x );
+
+gsorthpBy( x.length, x, 1, clbk );
+console.log( x );
+```
+
+
+
+
+
+* * *
+
+
+
+## References
+
+- Williams, John William Joseph. 1964. "Algorithm 232: Heapsort." _Communications of the ACM_ 7 (6). New York, NY, USA: Association for Computing Machinery: 347–49. doi:[10.1145/512274.512284][@williams:1964a].
+- Floyd, Robert W. 1964. "Algorithm 245: Treesort." _Communications of the ACM_ 7 (12). New York, NY, USA: Association for Computing Machinery: 701. doi:[10.1145/355588.365103][@floyd:1964a].
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+[mdn-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
+
+[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
+
+[@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor
+
+[@williams:1964a]: https://doi.org/10.1145/512274.512284
+
+[@floyd:1964a]: https://doi.org/10.1145/355588.365103
+
+
+
+
+
+
+
+
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.mostly_sorted_few_uniques.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.mostly_sorted_few_uniques.js
new file mode 100644
index 000000000000..13ae7af63697
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.mostly_sorted_few_uniques.js
@@ -0,0 +1,149 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var uniform = require( '@stdlib/random/base/uniform' );
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var floor = require( '@stdlib/math/base/special/floor' );
+var format = require( '@stdlib/string/format' );
+var pkg = require( './../package.json' ).name;
+var gsorthpBy = require( './../lib/main.js' );
+
+
+// FUNCTIONS //
+
+/**
+* Callback function.
+*
+* @private
+* @param {number} a - first value
+* @param {number} b - second value
+* @returns {number} comparison result
+*/
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+/**
+* Create a benchmark function.
+*
+* @private
+* @param {PositiveInteger} iter - number of iterations
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( iter, len ) {
+ var tmp;
+ var sa;
+ var sb;
+ var a;
+ var b;
+ var x;
+ var i;
+ var j;
+
+ a = 1.0;
+ b = 10.0;
+
+ x = [];
+ for ( i = 0; i < iter; i++ ) {
+ tmp = [];
+ for ( j = 0; j < len; j++ ) {
+ sa = (b-a) * (j/len);
+ sb = sa / 2.0;
+ tmp.push( floor( uniform( a+sa, b+sb ) ) );
+ }
+ x.push( tmp );
+ }
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var xc;
+ var y;
+ var i;
+
+ xc = x.slice();
+ for ( i = 0; i < iter; i++ ) {
+ xc[ i ] = x[ i ].slice();
+ }
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ y = gsorthpBy( len, xc[ i ], 1, clbk );
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var opts;
+ var iter;
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ iter = 1e6;
+ min = 1; // 10^min
+ max = 4; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( iter, len );
+ opts = {
+ 'iterations': iter
+ };
+ bench( format( '%s::mostly_sorted,few_uniques:len=%d', pkg, len ), opts, f );
+ iter = floor( pow( iter, 3.0/4.0 ) );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.mostly_sorted_few_uniques.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.mostly_sorted_few_uniques.ndarray.js
new file mode 100644
index 000000000000..c23b07b04e93
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.mostly_sorted_few_uniques.ndarray.js
@@ -0,0 +1,149 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var uniform = require( '@stdlib/random/base/uniform' );
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var floor = require( '@stdlib/math/base/special/floor' );
+var format = require( '@stdlib/string/format' );
+var pkg = require( './../package.json' ).name;
+var gsorthpBy = require( './../lib/ndarray.js' );
+
+
+// FUNCTIONS //
+
+/**
+* Callback function.
+*
+* @private
+* @param {number} a - first value
+* @param {number} b - second value
+* @returns {number} comparison result
+*/
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+/**
+* Create a benchmark function.
+*
+* @private
+* @param {PositiveInteger} iter - number of iterations
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( iter, len ) {
+ var tmp;
+ var sa;
+ var sb;
+ var a;
+ var b;
+ var x;
+ var i;
+ var j;
+
+ a = 1.0;
+ b = 10.0;
+
+ x = [];
+ for ( i = 0; i < iter; i++ ) {
+ tmp = [];
+ for ( j = 0; j < len; j++ ) {
+ sa = (b-a) * (j/len);
+ sb = sa / 2.0;
+ tmp.push( floor( uniform( a+sa, b+sb ) ) );
+ }
+ x.push( tmp );
+ }
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var xc;
+ var y;
+ var i;
+
+ xc = x.slice();
+ for ( i = 0; i < iter; i++ ) {
+ xc[ i ] = x[ i ].slice();
+ }
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ y = gsorthpBy( len, xc[ i ], 1, 0, clbk );
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var opts;
+ var iter;
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ iter = 1e6;
+ min = 1; // 10^min
+ max = 4; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( iter, len );
+ opts = {
+ 'iterations': iter
+ };
+ bench( format( '%s::mostly_sorted,few_uniques:ndarray:len=%d', pkg, len ), opts, f );
+ iter = floor( pow( iter, 3.0/4.0 ) );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.mostly_sorted_random.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.mostly_sorted_random.js
new file mode 100644
index 000000000000..9b20c8645e07
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.mostly_sorted_random.js
@@ -0,0 +1,140 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var randu = require( '@stdlib/random/base/randu' );
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var floor = require( '@stdlib/math/base/special/floor' );
+var format = require( '@stdlib/string/format' );
+var pkg = require( './../package.json' ).name;
+var gsorthpBy = require( './../lib/main.js' );
+
+
+// FUNCTIONS //
+
+/**
+* Callback function.
+*
+* @private
+* @param {number} a - first value
+* @param {number} b - second value
+* @returns {number} comparison result
+*/
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+/**
+* Create a benchmark function.
+*
+* @private
+* @param {PositiveInteger} iter - number of iterations
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( iter, len ) {
+ var tmp;
+ var x;
+ var i;
+ var j;
+
+ x = [];
+ for ( i = 0; i < iter; i++ ) {
+ tmp = [];
+ for ( j = 0; j < len; j++ ) {
+ tmp.push( randu() * j );
+ }
+ x.push( tmp );
+ }
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var xc;
+ var y;
+ var i;
+
+ xc = x.slice();
+ for ( i = 0; i < iter; i++ ) {
+ xc[ i ] = x[ i ].slice();
+ }
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ y = gsorthpBy( len, xc[ i ], 1, clbk );
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var opts;
+ var iter;
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ iter = 1e6;
+ min = 1; // 10^min
+ max = 4; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( iter, len );
+ opts = {
+ 'iterations': iter
+ };
+ bench( format( '%s::mostly_sorted,random:len=%d', pkg, len ), opts, f );
+ iter = floor( pow( iter, 3.0/4.0 ) );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.mostly_sorted_random.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.mostly_sorted_random.ndarray.js
new file mode 100644
index 000000000000..8ec93b26b99d
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.mostly_sorted_random.ndarray.js
@@ -0,0 +1,140 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var randu = require( '@stdlib/random/base/randu' );
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var floor = require( '@stdlib/math/base/special/floor' );
+var format = require( '@stdlib/string/format' );
+var pkg = require( './../package.json' ).name;
+var gsorthpBy = require( './../lib/ndarray.js' );
+
+
+// FUNCTIONS //
+
+/**
+* Callback function.
+*
+* @private
+* @param {number} a - first value
+* @param {number} b - second value
+* @returns {number} comparison result
+*/
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+/**
+* Create a benchmark function.
+*
+* @private
+* @param {PositiveInteger} iter - number of iterations
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( iter, len ) {
+ var tmp;
+ var x;
+ var i;
+ var j;
+
+ x = [];
+ for ( i = 0; i < iter; i++ ) {
+ tmp = [];
+ for ( j = 0; j < len; j++ ) {
+ tmp.push( randu() * j );
+ }
+ x.push( tmp );
+ }
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var xc;
+ var y;
+ var i;
+
+ xc = x.slice();
+ for ( i = 0; i < iter; i++ ) {
+ xc[ i ] = x[ i ].slice();
+ }
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ y = gsorthpBy( len, xc[ i ], 1, 0, clbk );
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var opts;
+ var iter;
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ iter = 1e6;
+ min = 1; // 10^min
+ max = 4; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( iter, len );
+ opts = {
+ 'iterations': iter
+ };
+ bench( format( '%s::mostly_sorted,random:ndarray:len=%d', pkg, len ), opts, f );
+ iter = floor( pow( iter, 3.0/4.0 ) );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_mostly_sorted_few_uniques.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_mostly_sorted_few_uniques.js
new file mode 100644
index 000000000000..8d0ce0171f37
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_mostly_sorted_few_uniques.js
@@ -0,0 +1,149 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var uniform = require( '@stdlib/random/base/uniform' );
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var floor = require( '@stdlib/math/base/special/floor' );
+var format = require( '@stdlib/string/format' );
+var pkg = require( './../package.json' ).name;
+var gsorthpBy = require( './../lib/main.js' );
+
+
+// FUNCTIONS //
+
+/**
+* Callback function.
+*
+* @private
+* @param {number} a - first value
+* @param {number} b - second value
+* @returns {number} comparison result
+*/
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+/**
+* Create a benchmark function.
+*
+* @private
+* @param {PositiveInteger} iter - number of iterations
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( iter, len ) {
+ var tmp;
+ var sa;
+ var sb;
+ var a;
+ var b;
+ var x;
+ var i;
+ var j;
+
+ a = -10.0;
+ b = -1.0;
+
+ x = [];
+ for ( i = 0; i < iter; i++ ) {
+ tmp = [];
+ for ( j = 0; j < len; j++ ) {
+ sb = (b-a) * (j/len);
+ sa = sb / 2.0;
+ tmp.push( floor( uniform( a-sa, b-sb ) ) );
+ }
+ x.push( tmp );
+ }
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var xc;
+ var y;
+ var i;
+
+ xc = x.slice();
+ for ( i = 0; i < iter; i++ ) {
+ xc[ i ] = x[ i ].slice();
+ }
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ y = gsorthpBy( len, xc[ i ], 1, clbk );
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var opts;
+ var iter;
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ iter = 1e6;
+ min = 1; // 10^min
+ max = 4; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( iter, len );
+ opts = {
+ 'iterations': iter
+ };
+ bench( format( '%s::reverse_mostly_sorted,few_uniques:len=%d', pkg, len ), opts, f );
+ iter = floor( pow( iter, 3.0/4.0 ) );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_mostly_sorted_few_uniques.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_mostly_sorted_few_uniques.ndarray.js
new file mode 100644
index 000000000000..fd96b12525cd
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_mostly_sorted_few_uniques.ndarray.js
@@ -0,0 +1,149 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var uniform = require( '@stdlib/random/base/uniform' );
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var floor = require( '@stdlib/math/base/special/floor' );
+var format = require( '@stdlib/string/format' );
+var pkg = require( './../package.json' ).name;
+var gsorthpBy = require( './../lib/ndarray.js' );
+
+
+// FUNCTIONS //
+
+/**
+* Callback function.
+*
+* @private
+* @param {number} a - first value
+* @param {number} b - second value
+* @returns {number} comparison result
+*/
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+/**
+* Create a benchmark function.
+*
+* @private
+* @param {PositiveInteger} iter - number of iterations
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( iter, len ) {
+ var tmp;
+ var sa;
+ var sb;
+ var a;
+ var b;
+ var x;
+ var i;
+ var j;
+
+ a = -10.0;
+ b = -1.0;
+
+ x = [];
+ for ( i = 0; i < iter; i++ ) {
+ tmp = [];
+ for ( j = 0; j < len; j++ ) {
+ sb = (b-a) * (j/len);
+ sa = sb / 2.0;
+ tmp.push( floor( uniform( a-sa, b-sb ) ) );
+ }
+ x.push( tmp );
+ }
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var xc;
+ var y;
+ var i;
+
+ xc = x.slice();
+ for ( i = 0; i < iter; i++ ) {
+ xc[ i ] = x[ i ].slice();
+ }
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ y = gsorthpBy( len, xc[ i ], 1, 0, clbk );
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var opts;
+ var iter;
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ iter = 1e6;
+ min = 1; // 10^min
+ max = 4; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( iter, len );
+ opts = {
+ 'iterations': iter
+ };
+ bench( format( '%s::reverse_mostly_sorted,few_uniques:ndarray:len=%d', pkg, len ), opts, f );
+ iter = floor( pow( iter, 3.0/4.0 ) );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_mostly_sorted_random.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_mostly_sorted_random.js
new file mode 100644
index 000000000000..d8f23a5d7ff7
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_mostly_sorted_random.js
@@ -0,0 +1,140 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var randu = require( '@stdlib/random/base/randu' );
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var floor = require( '@stdlib/math/base/special/floor' );
+var format = require( '@stdlib/string/format' );
+var pkg = require( './../package.json' ).name;
+var gsorthpBy = require( './../lib/main.js' );
+
+
+// FUNCTIONS //
+
+/**
+* Callback function.
+*
+* @private
+* @param {number} a - first value
+* @param {number} b - second value
+* @returns {number} comparison result
+*/
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+/**
+* Create a benchmark function.
+*
+* @private
+* @param {PositiveInteger} iter - number of iterations
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( iter, len ) {
+ var tmp;
+ var x;
+ var i;
+ var j;
+
+ x = [];
+ for ( i = 0; i < iter; i++ ) {
+ tmp = [];
+ for ( j = 0; j < len; j++ ) {
+ tmp.push( -1.0 * randu() * j );
+ }
+ x.push( tmp );
+ }
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var xc;
+ var y;
+ var i;
+
+ xc = x.slice();
+ for ( i = 0; i < iter; i++ ) {
+ xc[ i ] = x[ i ].slice();
+ }
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ y = gsorthpBy( len, xc[ i ], 1, clbk );
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var opts;
+ var iter;
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ iter = 1e6;
+ min = 1; // 10^min
+ max = 4; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( iter, len );
+ opts = {
+ 'iterations': iter
+ };
+ bench( format( '%s::reverse_mostly_sorted,random:len=%d', pkg, len ), opts, f );
+ iter = floor( pow( iter, 3.0/4.0 ) );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_mostly_sorted_random.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_mostly_sorted_random.ndarray.js
new file mode 100644
index 000000000000..7d9ae981a89f
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_mostly_sorted_random.ndarray.js
@@ -0,0 +1,140 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var randu = require( '@stdlib/random/base/randu' );
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var floor = require( '@stdlib/math/base/special/floor' );
+var format = require( '@stdlib/string/format' );
+var pkg = require( './../package.json' ).name;
+var gsorthpBy = require( './../lib/ndarray.js' );
+
+
+// FUNCTIONS //
+
+/**
+* Callback function.
+*
+* @private
+* @param {number} a - first value
+* @param {number} b - second value
+* @returns {number} comparison result
+*/
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+/**
+* Create a benchmark function.
+*
+* @private
+* @param {PositiveInteger} iter - number of iterations
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( iter, len ) {
+ var tmp;
+ var x;
+ var i;
+ var j;
+
+ x = [];
+ for ( i = 0; i < iter; i++ ) {
+ tmp = [];
+ for ( j = 0; j < len; j++ ) {
+ tmp.push( -1.0 * randu() * j );
+ }
+ x.push( tmp );
+ }
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var xc;
+ var y;
+ var i;
+
+ xc = x.slice();
+ for ( i = 0; i < iter; i++ ) {
+ xc[ i ] = x[ i ].slice();
+ }
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ y = gsorthpBy( len, xc[ i ], 1, 0, clbk );
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var opts;
+ var iter;
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ iter = 1e6;
+ min = 1; // 10^min
+ max = 4; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( iter, len );
+ opts = {
+ 'iterations': iter
+ };
+ bench( format( '%s::reverse_mostly_sorted,random:ndarray:len=%d', pkg, len ), opts, f );
+ iter = floor( pow( iter, 3.0/4.0 ) );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_sorted_few_uniques.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_sorted_few_uniques.js
new file mode 100644
index 000000000000..780e5e90399e
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_sorted_few_uniques.js
@@ -0,0 +1,150 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var floor = require( '@stdlib/math/base/special/floor' );
+var format = require( '@stdlib/string/format' );
+var pkg = require( './../package.json' ).name;
+var gsorthpBy = require( './../lib/main.js' );
+
+
+// FUNCTIONS //
+
+/**
+* Callback function.
+*
+* @private
+* @param {number} a - first value
+* @param {number} b - second value
+* @returns {number} comparison result
+*/
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+/**
+* Create a benchmark function.
+*
+* @private
+* @param {PositiveInteger} iter - number of iterations
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( iter, len ) {
+ var randi;
+ var tmp;
+ var M;
+ var x;
+ var v;
+ var i;
+ var j;
+
+ randi = discreteUniform( 1, 10 );
+ M = floor( len*0.333 );
+
+ x = [];
+ for ( i = 0; i < iter; i++ ) {
+ tmp = [];
+ v = randi();
+ for ( j = 0; j < len; j++ ) {
+ if ( i % M === 0 ) {
+ v -= randi();
+ }
+ tmp.push( v );
+ }
+ x.push( tmp );
+ }
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var xc;
+ var y;
+ var i;
+
+ xc = x.slice();
+ for ( i = 0; i < iter; i++ ) {
+ xc[ i ] = x[ i ].slice();
+ }
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ y = gsorthpBy( len, xc[ i ], 1, clbk );
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var opts;
+ var iter;
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ iter = 1e6;
+ min = 1; // 10^min
+ max = 4; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( iter, len );
+ opts = {
+ 'iterations': iter
+ };
+ bench( format( '%s::reverse_sorted,few_uniques:len=%d', pkg, len ), opts, f );
+ iter = floor( pow( iter, 3.0/4.0 ) );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_sorted_few_uniques.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_sorted_few_uniques.ndarray.js
new file mode 100644
index 000000000000..910c7ea74097
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_sorted_few_uniques.ndarray.js
@@ -0,0 +1,150 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var floor = require( '@stdlib/math/base/special/floor' );
+var format = require( '@stdlib/string/format' );
+var pkg = require( './../package.json' ).name;
+var gsorthpBy = require( './../lib/ndarray.js' );
+
+
+// FUNCTIONS //
+
+/**
+* Callback function.
+*
+* @private
+* @param {number} a - first value
+* @param {number} b - second value
+* @returns {number} comparison result
+*/
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+/**
+* Create a benchmark function.
+*
+* @private
+* @param {PositiveInteger} iter - number of iterations
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( iter, len ) {
+ var randi;
+ var tmp;
+ var M;
+ var x;
+ var v;
+ var i;
+ var j;
+
+ randi = discreteUniform( 1, 10 );
+ M = floor( len*0.333 );
+
+ x = [];
+ for ( i = 0; i < iter; i++ ) {
+ tmp = [];
+ v = randi();
+ for ( j = 0; j < len; j++ ) {
+ if ( i % M === 0 ) {
+ v -= randi();
+ }
+ tmp.push( v );
+ }
+ x.push( tmp );
+ }
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var xc;
+ var y;
+ var i;
+
+ xc = x.slice();
+ for ( i = 0; i < iter; i++ ) {
+ xc[ i ] = x[ i ].slice();
+ }
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ y = gsorthpBy( len, xc[ i ], 1, 0, clbk );
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var opts;
+ var iter;
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ iter = 1e6;
+ min = 1; // 10^min
+ max = 4; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( iter, len );
+ opts = {
+ 'iterations': iter
+ };
+ bench( format( '%s::reverse_sorted,few_uniques:ndarray:len=%d', pkg, len ), opts, f );
+ iter = floor( pow( iter, 3.0/4.0 ) );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_sorted_random.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_sorted_random.js
new file mode 100644
index 000000000000..8d5cb02c28db
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_sorted_random.js
@@ -0,0 +1,140 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var randu = require( '@stdlib/random/base/randu' );
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var floor = require( '@stdlib/math/base/special/floor' );
+var format = require( '@stdlib/string/format' );
+var pkg = require( './../package.json' ).name;
+var gsorthpBy = require( './../lib/main.js' );
+
+
+// FUNCTIONS //
+
+/**
+* Callback function.
+*
+* @private
+* @param {number} a - first value
+* @param {number} b - second value
+* @returns {number} comparison result
+*/
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+/**
+* Create a benchmark function.
+*
+* @private
+* @param {PositiveInteger} iter - number of iterations
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( iter, len ) {
+ var tmp;
+ var x;
+ var i;
+ var j;
+
+ x = [];
+ for ( i = 0; i < iter; i++ ) {
+ tmp = [];
+ for ( j = 0; j < len; j++ ) {
+ tmp.push( iter - j - randu() );
+ }
+ x.push( tmp );
+ }
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var xc;
+ var y;
+ var i;
+
+ xc = x.slice();
+ for ( i = 0; i < iter; i++ ) {
+ xc[ i ] = x[ i ].slice();
+ }
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ y = gsorthpBy( len, xc[ i ], 1, clbk );
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var opts;
+ var iter;
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ iter = 1e6;
+ min = 1; // 10^min
+ max = 4; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( iter, len );
+ opts = {
+ 'iterations': iter
+ };
+ bench( format( '%s::reverse_sorted,random:len=%d', pkg, len ), opts, f );
+ iter = floor( pow( iter, 3.0/4.0 ) );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_sorted_random.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_sorted_random.ndarray.js
new file mode 100644
index 000000000000..c54ba82fe103
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.rev_sorted_random.ndarray.js
@@ -0,0 +1,140 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var randu = require( '@stdlib/random/base/randu' );
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var floor = require( '@stdlib/math/base/special/floor' );
+var format = require( '@stdlib/string/format' );
+var pkg = require( './../package.json' ).name;
+var gsorthpBy = require( './../lib/ndarray.js' );
+
+
+// FUNCTIONS //
+
+/**
+* Callback function.
+*
+* @private
+* @param {number} a - first value
+* @param {number} b - second value
+* @returns {number} comparison result
+*/
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+/**
+* Create a benchmark function.
+*
+* @private
+* @param {PositiveInteger} iter - number of iterations
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( iter, len ) {
+ var tmp;
+ var x;
+ var i;
+ var j;
+
+ x = [];
+ for ( i = 0; i < iter; i++ ) {
+ tmp = [];
+ for ( j = 0; j < len; j++ ) {
+ tmp.push( iter - j - randu() );
+ }
+ x.push( tmp );
+ }
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var xc;
+ var y;
+ var i;
+
+ xc = x.slice();
+ for ( i = 0; i < iter; i++ ) {
+ xc[ i ] = x[ i ].slice();
+ }
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ y = gsorthpBy( len, xc[ i ], 1, 0, clbk );
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var opts;
+ var iter;
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ iter = 1e6;
+ min = 1; // 10^min
+ max = 4; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( iter, len );
+ opts = {
+ 'iterations': iter
+ };
+ bench( format( '%s::reverse_sorted,random:ndarray:len=%d', pkg, len ), opts, f );
+ iter = floor( pow( iter, 3.0/4.0 ) );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.sorted_few_uniques.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.sorted_few_uniques.js
new file mode 100644
index 000000000000..ababca912a6e
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.sorted_few_uniques.js
@@ -0,0 +1,150 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var floor = require( '@stdlib/math/base/special/floor' );
+var format = require( '@stdlib/string/format' );
+var pkg = require( './../package.json' ).name;
+var gsorthpBy = require( './../lib/main.js' );
+
+
+// FUNCTIONS //
+
+/**
+* Callback function.
+*
+* @private
+* @param {number} a - first value
+* @param {number} b - second value
+* @returns {number} comparison result
+*/
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+/**
+* Create a benchmark function.
+*
+* @private
+* @param {PositiveInteger} iter - number of iterations
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( iter, len ) {
+ var randi;
+ var tmp;
+ var M;
+ var x;
+ var v;
+ var i;
+ var j;
+
+ randi = discreteUniform( 1, 10 );
+ M = floor( len*0.333 );
+
+ x = [];
+ for ( i = 0; i < iter; i++ ) {
+ tmp = [];
+ v = randi();
+ for ( j = 0; j < len; j++ ) {
+ if ( j % M === 0 ) {
+ v += randi();
+ }
+ tmp.push( v );
+ }
+ x.push( tmp );
+ }
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var xc;
+ var y;
+ var i;
+
+ xc = x.slice();
+ for ( i = 0; i < iter; i++ ) {
+ xc[ i ] = x[ i ].slice();
+ }
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ y = gsorthpBy( len, xc[ i ], 1, clbk );
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var opts;
+ var iter;
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ iter = 1e6;
+ min = 1; // 10^min
+ max = 4; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( iter, len );
+ opts = {
+ 'iterations': iter
+ };
+ bench( format( '%s::sorted,few_uniques:len=%d', pkg, len ), opts, f );
+ iter = floor( pow( iter, 3.0/4.0 ) );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.sorted_few_uniques.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.sorted_few_uniques.ndarray.js
new file mode 100644
index 000000000000..ed6798fed6e9
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.sorted_few_uniques.ndarray.js
@@ -0,0 +1,150 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var floor = require( '@stdlib/math/base/special/floor' );
+var format = require( '@stdlib/string/format' );
+var pkg = require( './../package.json' ).name;
+var gsorthpBy = require( './../lib/ndarray.js' );
+
+
+// FUNCTIONS //
+
+/**
+* Callback function.
+*
+* @private
+* @param {number} a - first value
+* @param {number} b - second value
+* @returns {number} comparison result
+*/
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+/**
+* Create a benchmark function.
+*
+* @private
+* @param {PositiveInteger} iter - number of iterations
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( iter, len ) {
+ var randi;
+ var tmp;
+ var M;
+ var x;
+ var v;
+ var i;
+ var j;
+
+ randi = discreteUniform( 1, 10 );
+ M = floor( len*0.333 );
+
+ x = [];
+ for ( i = 0; i < iter; i++ ) {
+ tmp = [];
+ v = randi();
+ for ( j = 0; j < len; j++ ) {
+ if ( j % M === 0 ) {
+ v += randi();
+ }
+ tmp.push( v );
+ }
+ x.push( tmp );
+ }
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var xc;
+ var y;
+ var i;
+
+ xc = x.slice();
+ for ( i = 0; i < iter; i++ ) {
+ xc[ i ] = x[ i ].slice();
+ }
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ y = gsorthpBy( len, xc[ i ], 1, 0, clbk );
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var opts;
+ var iter;
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ iter = 1e6;
+ min = 1; // 10^min
+ max = 4; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( iter, len );
+ opts = {
+ 'iterations': iter
+ };
+ bench( format( '%s::sorted,few_uniques:ndarray:len=%d', pkg, len ), opts, f );
+ iter = floor( pow( iter, 3.0/4.0 ) );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.sorted_random.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.sorted_random.js
new file mode 100644
index 000000000000..60a96cc4b59a
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.sorted_random.js
@@ -0,0 +1,140 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var randu = require( '@stdlib/random/base/randu' );
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var floor = require( '@stdlib/math/base/special/floor' );
+var format = require( '@stdlib/string/format' );
+var pkg = require( './../package.json' ).name;
+var gsorthpBy = require( './../lib/main.js' );
+
+
+// FUNCTIONS //
+
+/**
+* Callback function.
+*
+* @private
+* @param {number} a - first value
+* @param {number} b - second value
+* @returns {number} comparison result
+*/
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+/**
+* Create a benchmark function.
+*
+* @private
+* @param {PositiveInteger} iter - number of iterations
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( iter, len ) {
+ var tmp;
+ var x;
+ var i;
+ var j;
+
+ x = [];
+ for ( i = 0; i < iter; i++ ) {
+ tmp = [];
+ for ( j = 0; j < len; j++ ) {
+ tmp.push( randu() + j );
+ }
+ x.push( tmp );
+ }
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var xc;
+ var y;
+ var i;
+
+ xc = x.slice();
+ for ( i = 0; i < iter; i++ ) {
+ xc[ i ] = x[ i ].slice();
+ }
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ y = gsorthpBy( len, xc[ i ], 1, clbk );
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var opts;
+ var iter;
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ iter = 1e6;
+ min = 1; // 10^min
+ max = 4; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( iter, len );
+ opts = {
+ 'iterations': iter
+ };
+ bench( format( '%s::sorted,random:len=%d', pkg, len ), opts, f );
+ iter = floor( pow( iter, 3.0/4.0 ) );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.sorted_random.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.sorted_random.ndarray.js
new file mode 100644
index 000000000000..76082a9409f1
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.sorted_random.ndarray.js
@@ -0,0 +1,140 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var randu = require( '@stdlib/random/base/randu' );
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var floor = require( '@stdlib/math/base/special/floor' );
+var format = require( '@stdlib/string/format' );
+var pkg = require( './../package.json' ).name;
+var gsorthpBy = require( './../lib/ndarray.js' );
+
+
+// FUNCTIONS //
+
+/**
+* Callback function.
+*
+* @private
+* @param {number} a - first value
+* @param {number} b - second value
+* @returns {number} comparison result
+*/
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+/**
+* Create a benchmark function.
+*
+* @private
+* @param {PositiveInteger} iter - number of iterations
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( iter, len ) {
+ var tmp;
+ var x;
+ var i;
+ var j;
+
+ x = [];
+ for ( i = 0; i < iter; i++ ) {
+ tmp = [];
+ for ( j = 0; j < len; j++ ) {
+ tmp.push( randu() + j );
+ }
+ x.push( tmp );
+ }
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var xc;
+ var y;
+ var i;
+
+ xc = x.slice();
+ for ( i = 0; i < iter; i++ ) {
+ xc[ i ] = x[ i ].slice();
+ }
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ y = gsorthpBy( len, xc[ i ], 1, 0, clbk );
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var opts;
+ var iter;
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ iter = 1e6;
+ min = 1; // 10^min
+ max = 4; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( iter, len );
+ opts = {
+ 'iterations': iter
+ };
+ bench( format( '%s::sorted,random:ndarray:len=%d', pkg, len ), opts, f );
+ iter = floor( pow( iter, 3.0/4.0 ) );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.unsorted_few_uniques.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.unsorted_few_uniques.js
new file mode 100644
index 000000000000..00f0dab0d904
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.unsorted_few_uniques.js
@@ -0,0 +1,143 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var floor = require( '@stdlib/math/base/special/floor' );
+var format = require( '@stdlib/string/format' );
+var pkg = require( './../package.json' ).name;
+var gsorthpBy = require( './../lib/main.js' );
+
+
+// FUNCTIONS //
+
+/**
+* Callback function.
+*
+* @private
+* @param {number} a - first value
+* @param {number} b - second value
+* @returns {number} comparison result
+*/
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+/**
+* Create a benchmark function.
+*
+* @private
+* @param {PositiveInteger} iter - number of iterations
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( iter, len ) {
+ var randi;
+ var tmp;
+ var x;
+ var i;
+ var j;
+
+ randi = discreteUniform( 1, 10 );
+
+ x = [];
+ for ( i = 0; i < iter; i++ ) {
+ tmp = [];
+ for ( j = 0; j < len; j++ ) {
+ tmp.push( randi() );
+ }
+ x.push( tmp );
+ }
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var xc;
+ var y;
+ var i;
+
+ xc = x.slice();
+ for ( i = 0; i < iter; i++ ) {
+ xc[ i ] = x[ i ].slice();
+ }
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ y = gsorthpBy( len, xc[ i ], 1, clbk );
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var opts;
+ var iter;
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ iter = 1e6;
+ min = 1; // 10^min
+ max = 4; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( iter, len );
+ opts = {
+ 'iterations': iter
+ };
+ bench( format( '%s::unsorted,few_uniques:len=%d', pkg, len ), opts, f );
+ iter = floor( pow( iter, 3.0/4.0 ) );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.unsorted_few_uniques.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.unsorted_few_uniques.ndarray.js
new file mode 100644
index 000000000000..7599f088597a
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.unsorted_few_uniques.ndarray.js
@@ -0,0 +1,143 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var floor = require( '@stdlib/math/base/special/floor' );
+var format = require( '@stdlib/string/format' );
+var pkg = require( './../package.json' ).name;
+var gsorthpBy = require( './../lib/ndarray.js' );
+
+
+// FUNCTIONS //
+
+/**
+* Callback function.
+*
+* @private
+* @param {number} a - first value
+* @param {number} b - second value
+* @returns {number} comparison result
+*/
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+/**
+* Create a benchmark function.
+*
+* @private
+* @param {PositiveInteger} iter - number of iterations
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( iter, len ) {
+ var randi;
+ var tmp;
+ var x;
+ var i;
+ var j;
+
+ randi = discreteUniform( 1, 10 );
+
+ x = [];
+ for ( i = 0; i < iter; i++ ) {
+ tmp = [];
+ for ( j = 0; j < len; j++ ) {
+ tmp.push( randi() );
+ }
+ x.push( tmp );
+ }
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var xc;
+ var y;
+ var i;
+
+ xc = x.slice();
+ for ( i = 0; i < iter; i++ ) {
+ xc[ i ] = x[ i ].slice();
+ }
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ y = gsorthpBy( len, xc[ i ], 1, 0, clbk );
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var opts;
+ var iter;
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ iter = 1e6;
+ min = 1; // 10^min
+ max = 4; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( iter, len );
+ opts = {
+ 'iterations': iter
+ };
+ bench( format( '%s::unsorted,few_uniques:ndarray:len=%d', pkg, len ), opts, f );
+ iter = floor( pow( iter, 3.0/4.0 ) );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.unsorted_random.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.unsorted_random.js
new file mode 100644
index 000000000000..48a6341b5c07
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.unsorted_random.js
@@ -0,0 +1,140 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var randu = require( '@stdlib/random/base/randu' );
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var floor = require( '@stdlib/math/base/special/floor' );
+var format = require( '@stdlib/string/format' );
+var pkg = require( './../package.json' ).name;
+var gsorthpBy = require( './../lib/main.js' );
+
+
+// FUNCTIONS //
+
+/**
+* Callback function.
+*
+* @private
+* @param {number} a - first value
+* @param {number} b - second value
+* @returns {number} comparison result
+*/
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+/**
+* Create a benchmark function.
+*
+* @private
+* @param {PositiveInteger} iter - number of iterations
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( iter, len ) {
+ var tmp;
+ var x;
+ var i;
+ var j;
+
+ x = [];
+ for ( i = 0; i < iter; i++ ) {
+ tmp = [];
+ for ( j = 0; j < len; j++ ) {
+ tmp.push( (randu()*20.0) - 10.0 );
+ }
+ x.push( tmp );
+ }
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var xc;
+ var y;
+ var i;
+
+ xc = x.slice();
+ for ( i = 0; i < iter; i++ ) {
+ xc[ i ] = x[ i ].slice();
+ }
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ y = gsorthpBy( len, xc[ i ], 1, clbk );
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var opts;
+ var iter;
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ iter = 1e6;
+ min = 1; // 10^min
+ max = 4; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( iter, len );
+ opts = {
+ 'iterations': iter
+ };
+ bench( format( '%s::unsorted,random:len=%d', pkg, len ), opts, f );
+ iter = floor( pow( iter, 3.0/4.0 ) );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.unsorted_random.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.unsorted_random.ndarray.js
new file mode 100644
index 000000000000..318968edb9dc
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/benchmark/benchmark.unsorted_random.ndarray.js
@@ -0,0 +1,140 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var randu = require( '@stdlib/random/base/randu' );
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var floor = require( '@stdlib/math/base/special/floor' );
+var format = require( '@stdlib/string/format' );
+var pkg = require( './../package.json' ).name;
+var gsorthpBy = require( './../lib/ndarray.js' );
+
+
+// FUNCTIONS //
+
+/**
+* Callback function.
+*
+* @private
+* @param {number} a - first value
+* @param {number} b - second value
+* @returns {number} comparison result
+*/
+function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+/**
+* Create a benchmark function.
+*
+* @private
+* @param {PositiveInteger} iter - number of iterations
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( iter, len ) {
+ var tmp;
+ var x;
+ var i;
+ var j;
+
+ x = [];
+ for ( i = 0; i < iter; i++ ) {
+ tmp = [];
+ for ( j = 0; j < len; j++ ) {
+ tmp.push( (randu()*20.0) - 10.0 );
+ }
+ x.push( tmp );
+ }
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var xc;
+ var y;
+ var i;
+
+ xc = x.slice();
+ for ( i = 0; i < iter; i++ ) {
+ xc[ i ] = x[ i ].slice();
+ }
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ y = gsorthpBy( len, xc[ i ], 1, 0, clbk );
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( isnan( y[ i%len ] ) ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var opts;
+ var iter;
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ iter = 1e6;
+ min = 1; // 10^min
+ max = 4; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( iter, len );
+ opts = {
+ 'iterations': iter
+ };
+ bench( format( '%s::unsorted,random:ndarray:len=%d', pkg, len ), opts, f );
+ iter = floor( pow( iter, 3.0/4.0 ) );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/docs/repl.txt
new file mode 100644
index 000000000000..38902de70df7
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/docs/repl.txt
@@ -0,0 +1,164 @@
+
+{{alias}}( N, x, strideX, clbk[, thisArg] )
+ Sorts a strided array using heapsort according to a provided callback
+ function.
+
+ The `N` and stride parameters determine which elements in the strided array
+ are accessed at runtime.
+
+ Indexing is relative to the first index. To introduce an offset, use typed
+ array views.
+
+ If `N <= 0`, the function returns `x` unchanged.
+
+ The callback function should return a negative value if `a` should come
+ before `b`, a positive value if `a` should come after `b`, and zero if `a`
+ and `b` are equivalent.
+
+ 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 strided array elements which are equal or equivalent.
+
+ The input strided array is sorted *in-place* (i.e., the input strided array
+ is *mutated*).
+
+ Parameters
+ ----------
+ N: integer
+ Number of indexed elements.
+
+ x: Array|TypedArray
+ Input array.
+
+ strideX: integer
+ Stride length.
+
+ clbk: Function
+ Callback function.
+
+ thisArg: any (optional)
+ Callback execution context.
+
+ Returns
+ -------
+ x: Array|TypedArray
+ Input array.
+
+ Examples
+ --------
+ // Standard Usage:
+ > function clbk( a, b ) {
+ ... if ( a < b ) {
+ ... return -1;
+ ... }
+ ... if ( a > b ) {
+ ... return 1;
+ ... }
+ ... return 0;
+ ... };
+ > var x = [ 1.0, -2.0, 3.0, -4.0 ];
+ > {{alias}}( x.length, x, 1, clbk )
+ [ -4.0, -2.0, 1.0, 3.0 ]
+
+ // Using `N` and stride parameters:
+ > function clbk( a, b ) {
+ ... if ( a > b ) {
+ ... return -1;
+ ... }
+ ... if ( a < b ) {
+ ... return 1;
+ ... }
+ ... return 0;
+ ... };
+ > x = [ 1.0, -2.0, 3.0, -4.0 ];
+ > {{alias}}( 2, x, 2, clbk )
+ [ 3.0, -2.0, 1.0, -4.0 ]
+
+ // Using view offsets:
+ > function clbk( a, b ) {
+ ... if ( a < b ) {
+ ... return -1;
+ ... }
+ ... if ( a > b ) {
+ ... return 1;
+ ... }
+ ... return 0;
+ ... };
+ > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0 ] );
+ > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
+ > {{alias}}( 2, x1, 2, clbk )
+ [ -4.0, 3.0, -2.0 ]
+ > x0
+ [ 1.0, -4.0, 3.0, -2.0 ]
+
+
+{{alias}}.ndarray( N, x, strideX, offsetX, clbk[, thisArg] )
+ Sorts a strided array using heapsort according to a provided callback
+ function and using alternative indexing semantics.
+
+ While typed array views mandate a view offset based on the underlying
+ buffer, the offset parameter supports indexing semantics based on a starting
+ index.
+
+ The callback function should return a negative value if `a` should come
+ before `b`, a positive value if `a` should come after `b`, and zero if `a`
+ and `b` are equivalent.
+
+ Parameters
+ ----------
+ N: integer
+ Number of indexed elements.
+
+ x: Array|TypedArray
+ Input array.
+
+ strideX: integer
+ Stride length.
+
+ offsetX: integer
+ Starting index.
+
+ clbk: Function
+ Callback function.
+
+ thisArg: any (optional)
+ Callback execution context.
+
+ Returns
+ -------
+ x: Array|TypedArray
+ Input array.
+
+ Examples
+ --------
+ // Standard Usage:
+ > function clbk( a, b ) {
+ ... if ( a < b ) {
+ ... return -1;
+ ... }
+ ... if ( a > b ) {
+ ... return 1;
+ ... }
+ ... return 0;
+ ... };
+ > var x = [ 1.0, -2.0, 3.0, -4.0 ];
+ > {{alias}}.ndarray( x.length, x, 1, 0, clbk )
+ [ -4.0, -2.0, 1.0, 3.0 ]
+
+ // Using an index offset:
+ > function clbk( a, b ) {
+ ... if ( a < b ) {
+ ... return -1;
+ ... }
+ ... if ( a > b ) {
+ ... return 1;
+ ... }
+ ... return 0;
+ ... };
+ > x = [ 1.0, -2.0, 3.0, -4.0 ];
+ > {{alias}}.ndarray( 2, x, 2, 1, clbk )
+ [ 1.0, -4.0, 3.0, -2.0 ]
+
+ See Also
+ --------
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/docs/types/index.d.ts
new file mode 100644
index 000000000000..f61010bd870b
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/docs/types/index.d.ts
@@ -0,0 +1,149 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+// TypeScript Version: 4.1
+
+///
+
+import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array';
+
+/**
+* Input array.
+*/
+type InputArray = NumericArray | Collection | AccessorArrayLike;
+
+/**
+* Comparator function.
+*
+* @param a - first value
+* @param b - second value
+* @param array - input array
+* @returns result
+*/
+type Callback = ( this: U, a: number, b: number, array: T ) => number;
+
+/**
+* Interface describing `gsorthpBy`.
+*/
+interface Routine {
+ /**
+ * Sorts a strided array using heapsort according to a provided callback function.
+ *
+ * @param N - number of indexed elements
+ * @param x - input array
+ * @param strideX - stride length
+ * @param clbk - callback function
+ * @param thisArg - execution context
+ * @returns `x`
+ *
+ * @example
+ * var x = [ 1.0, -2.0, 3.0, -4.0 ];
+ *
+ * function clbk( a, b ) {
+ * if ( a < b ) {
+ * return -1;
+ * }
+ * if ( a > b ) {
+ * return 1;
+ * }
+ * return 0;
+ * }
+ *
+ * gsorthpBy( x.length, x, 1, clbk );
+ * // x => [ -4.0, -2.0, 1.0, 3.0 ]
+ */
+ ( N: number, x: T, strideX: number, clbk: Callback, thisArg?: ThisParameterType> ): T;
+
+ /**
+ * Sorts a strided array using heapsort according to a provided callback function and using alternative indexing semantics.
+ *
+ * @param N - number of indexed elements
+ * @param x - input array
+ * @param strideX - stride length
+ * @param offsetX - starting index
+ * @param clbk - callback function
+ * @param thisArg - execution context
+ * @returns `x`
+ *
+ * @example
+ * var x = [ 1.0, -2.0, 3.0, -4.0 ];
+ *
+ * function clbk( a, b ) {
+ * if ( a < b ) {
+ * return -1;
+ * }
+ * if ( a > b ) {
+ * return 1;
+ * }
+ * return 0;
+ * }
+ *
+ * gsorthpBy.ndarray( x.length, x, 1, 0, clbk );
+ * // x => [ -4.0, -2.0, 1.0, 3.0 ]
+ */
+ ndarray( N: number, x: T, strideX: number, offsetX: number, clbk: Callback, thisArg?: ThisParameterType> ): T;
+}
+
+/**
+* Sorts a strided array using heapsort according to a provided callback function.
+*
+* @param N - number of indexed elements
+* @param x - input array
+* @param strideX - stride length
+* @param clbk - callback function
+* @param thisArg - execution context
+* @returns `x`
+*
+* @example
+* var x = [ 1.0, -2.0, 3.0, -4.0 ];
+*
+* function clbk( a, b ) {
+* if ( a < b ) {
+* return -1;
+* }
+* if ( a > b ) {
+* return 1;
+* }
+* return 0;
+* }
+*
+* gsorthpBy( x.length, x, 1, clbk );
+* // x => [ -4.0, -2.0, 1.0, 3.0 ]
+*
+* @example
+* var x = [ 1.0, -2.0, 3.0, -4.0 ];
+*
+* function clbk( a, b ) {
+* if ( a < b ) {
+* return -1;
+* }
+* if ( a > b ) {
+* return 1;
+* }
+* return 0;
+* }
+*
+* gsorthpBy.ndarray( x.length, x, 1, 0, clbk );
+* // x => [ -4.0, -2.0, 1.0, 3.0 ]
+*/
+declare var gsorthpBy: Routine;
+
+
+// EXPORTS //
+
+export = gsorthpBy;
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/docs/types/test.ts
new file mode 100644
index 000000000000..483c4b86599c
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/docs/types/test.ts
@@ -0,0 +1,208 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/* eslint-disable space-in-parens */
+
+import AccessorArray = require( '@stdlib/array/base/accessor' );
+import gsorthpBy = require( './index' );
+
+
+// FUNCTIONS //
+
+/**
+* Callback function.
+*
+* @param a - first value
+* @param b - second value
+* @returns comparison result
+*/
+function clbk( a: number, b: number ): number {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+}
+
+
+// TESTS //
+
+// The function returns a numeric array...
+{
+ const x = new Float64Array( 10 );
+
+ gsorthpBy( x.length, x, 1, clbk ); // $ExpectType Float64Array
+ gsorthpBy( x.length, new AccessorArray( x ), 1, clbk ); // $ExpectType AccessorArray
+}
+
+// The compiler throws an error if the function is provided a first argument which is not a number...
+{
+ const x = new Float64Array( 10 );
+
+ gsorthpBy( '10', x, 1, clbk ); // $ExpectError
+ gsorthpBy( true, x, 1, clbk ); // $ExpectError
+ gsorthpBy( false, x, 1, clbk ); // $ExpectError
+ gsorthpBy( null, x, 1, clbk ); // $ExpectError
+ gsorthpBy( undefined, x, 1, clbk ); // $ExpectError
+ gsorthpBy( [], x, 1, clbk ); // $ExpectError
+ gsorthpBy( {}, x, 1, clbk ); // $ExpectError
+ gsorthpBy( ( x: number ): number => x, x, 1, clbk ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a second argument which is not a numeric array...
+{
+ gsorthpBy( 10, 10, 1, clbk ); // $ExpectError
+ gsorthpBy( 10, '10', 1, clbk ); // $ExpectError
+ gsorthpBy( 10, true, 1, clbk ); // $ExpectError
+ gsorthpBy( 10, false, 1, clbk ); // $ExpectError
+ gsorthpBy( 10, null, 1, clbk ); // $ExpectError
+ gsorthpBy( 10, undefined, 1, clbk ); // $ExpectError
+ gsorthpBy( 10, [ '1' ], 1, clbk ); // $ExpectError
+ gsorthpBy( 10, {}, 1, clbk ); // $ExpectError
+ gsorthpBy( 10, ( x: number ): number => x, 1, clbk ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a third argument which is not a number...
+{
+ const x = new Float64Array( 10 );
+
+ gsorthpBy( x.length, x, '10', clbk ); // $ExpectError
+ gsorthpBy( x.length, x, true, clbk ); // $ExpectError
+ gsorthpBy( x.length, x, false, clbk ); // $ExpectError
+ gsorthpBy( x.length, x, null, clbk ); // $ExpectError
+ gsorthpBy( x.length, x, undefined, clbk ); // $ExpectError
+ gsorthpBy( x.length, x, [], clbk ); // $ExpectError
+ gsorthpBy( x.length, x, {}, clbk ); // $ExpectError
+ gsorthpBy( x.length, x, ( x: number ): number => x, clbk ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a fourth argument which is not a function...
+{
+ const x = new Float64Array( 10 );
+
+ gsorthpBy( x.length, x, 1, 10 ); // $ExpectError
+ gsorthpBy( x.length, x, 1, '10' ); // $ExpectError
+ gsorthpBy( x.length, x, 1, true ); // $ExpectError
+ gsorthpBy( x.length, x, 1, false ); // $ExpectError
+ gsorthpBy( x.length, x, 1, null ); // $ExpectError
+ gsorthpBy( x.length, x, 1, undefined ); // $ExpectError
+ gsorthpBy( x.length, x, 1, [] ); // $ExpectError
+ gsorthpBy( x.length, x, 1, {} ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided an unsupported number of arguments...
+{
+ const x = new Float64Array( 10 );
+
+ gsorthpBy(); // $ExpectError
+ gsorthpBy( x.length ); // $ExpectError
+ gsorthpBy( x.length, x ); // $ExpectError
+ gsorthpBy( x.length, x, 1 ); // $ExpectError
+ gsorthpBy( x.length, x, 1, clbk, {}, {} ); // $ExpectError
+}
+
+// Attached to main export is an `ndarray` method which returns a numeric array...
+{
+ const x = new Float64Array( 10 );
+
+ gsorthpBy.ndarray( x.length, x, 1, 0, clbk ); // $ExpectType Float64Array
+ gsorthpBy.ndarray( x.length, new AccessorArray( x ), 1, 0, clbk ); // $ExpectType AccessorArray
+}
+
+// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number...
+{
+ const x = new Float64Array( 10 );
+
+ gsorthpBy.ndarray( '10', x, 1, 0, clbk ); // $ExpectError
+ gsorthpBy.ndarray( true, x, 1, 0, clbk ); // $ExpectError
+ gsorthpBy.ndarray( false, x, 1, 0, clbk ); // $ExpectError
+ gsorthpBy.ndarray( null, x, 1, 0, clbk ); // $ExpectError
+ gsorthpBy.ndarray( undefined, x, 1, 0, clbk ); // $ExpectError
+ gsorthpBy.ndarray( [], x, 1, 0, clbk ); // $ExpectError
+ gsorthpBy.ndarray( {}, x, 1, 0, clbk ); // $ExpectError
+ gsorthpBy.ndarray( ( x: number ): number => x, x, 1, 0, clbk ); // $ExpectError
+}
+
+// The compiler throws an error if the `ndarray` method is provided a second argument which is not a numeric array...
+{
+ gsorthpBy.ndarray( 10, 10, 1, 0, clbk ); // $ExpectError
+ gsorthpBy.ndarray( 10, '10', 1, 0, clbk ); // $ExpectError
+ gsorthpBy.ndarray( 10, true, 1, 0, clbk ); // $ExpectError
+ gsorthpBy.ndarray( 10, false, 1, 0, clbk ); // $ExpectError
+ gsorthpBy.ndarray( 10, null, 1, 0, clbk ); // $ExpectError
+ gsorthpBy.ndarray( 10, undefined, 1, 0, clbk ); // $ExpectError
+ gsorthpBy.ndarray( 10, [ '1' ], 1, 0, clbk ); // $ExpectError
+ gsorthpBy.ndarray( 10, {}, 1, 0, clbk ); // $ExpectError
+ gsorthpBy.ndarray( 10, ( x: number ): number => x, 1, 0, clbk ); // $ExpectError
+}
+
+// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number...
+{
+ const x = new Float64Array( 10 );
+
+ gsorthpBy.ndarray( x.length, x, '10', 0, clbk ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, true, 0, clbk ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, false, 0, clbk ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, null, 0, clbk ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, undefined, 0, clbk ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, [], 0, clbk ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, {}, 0, clbk ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, ( x: number ): number => x, 0, clbk ); // $ExpectError
+}
+
+// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number...
+{
+ const x = new Float64Array( 10 );
+
+ gsorthpBy.ndarray( x.length, x, 1, '10', clbk ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, 1, true, clbk ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, 1, false, clbk ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, 1, null, clbk ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, 1, undefined, clbk ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, 1, [], clbk ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, 1, {}, clbk ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, 1, ( x: number ): number => x, clbk ); // $ExpectError
+}
+
+// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a function...
+{
+ const x = new Float64Array( 10 );
+
+ gsorthpBy.ndarray( x.length, x, 1, 0, 10 ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, 1, 0, '10' ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, 1, 0, true ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, 1, 0, false ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, 1, 0, null ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, 1, 0, undefined ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, 1, 0, [] ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, 1, 0, {} ); // $ExpectError
+}
+
+// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments...
+{
+ const x = new Float64Array( 10 );
+
+ gsorthpBy.ndarray(); // $ExpectError
+ gsorthpBy.ndarray( x.length ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, 1 ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, 1, 0 ); // $ExpectError
+ gsorthpBy.ndarray( x.length, x, 1, 0, clbk, {}, {} ); // $ExpectError
+}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/examples/index.js
new file mode 100644
index 000000000000..91938e15cd94
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/examples/index.js
@@ -0,0 +1,40 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
+var gsorthpBy = require( './../lib' );
+
+function clbk( a, b ) {
+ if ( a > b ) {
+ return -1;
+ }
+ if ( a < b ) {
+ return 1;
+ }
+ return 0;
+}
+
+var x = discreteUniform( 10, -100, 100, {
+ 'dtype': 'float64'
+});
+console.log( x );
+
+gsorthpBy( x.length, x, 1, clbk );
+console.log( x );
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/lib/accessors.js
new file mode 100644
index 000000000000..d2c2a2766304
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/lib/accessors.js
@@ -0,0 +1,167 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var floor = require( '@stdlib/math/base/special/floor' );
+
+
+// MAIN //
+
+/**
+* Sorts a strided array using heapsort according to a provided callback function.
+*
+* ## Notes
+*
+* - This implementation uses an in-place algorithm derived from the work of Floyd (1964).
+*
+* ## References
+*
+* - Williams, John William Joseph. 1964. "Algorithm 232: Heapsort." _Communications of the ACM_ 7 (6). New York, NY, USA: Association for Computing Machinery: 347–49. doi:[10.1145/512274.512284](https://doi.org/10.1145/512274.512284).
+* - Floyd, Robert W. 1964. "Algorithm 245: Treesort." _Communications of the ACM_ 7 (12). New York, NY, USA: Association for Computing Machinery: 701. doi:[10.1145/355588.365103](https://doi.org/10.1145/355588.365103).
+*
+* @private
+* @param {PositiveInteger} N - number of indexed elements
+* @param {Object} x - input array object
+* @param {Collection} x.data - input array data
+* @param {Array} x.accessors - array element accessors
+* @param {integer} strideX - stride length
+* @param {NonNegativeInteger} offsetX - starting index
+* @param {Callback} clbk - callback function
+* @param {*} [thisArg] - execution context
+* @returns {Object} `x`
+*
+* @example
+* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
+* var arraylike2object = require( '@stdlib/array/base/arraylike2object' );
+*
+* var x = [ 1.0, -2.0, 3.0, -4.0 ];
+*
+* function clbk( a, b ) {
+* if ( a < b ) {
+* return -1;
+* }
+* if ( a > b ) {
+* return 1;
+* }
+* return 0;
+* }
+*
+* gsorthpBy( x.length, arraylike2object( toAccessorArray( x ) ), 1, 0, clbk );
+*
+* console.log( x );
+* // => [ -4.0, -2.0, 1.0, 3.0 ]
+*/
+function gsorthpBy( N, x, strideX, offsetX, clbk, thisArg ) {
+ var parent;
+ var child;
+ var xbuf;
+ var xget;
+ var xset;
+ var cmp;
+ var v1;
+ var v2;
+ var n;
+ var t;
+ var i;
+ var j;
+ var k;
+
+ // Cache reference to array data:
+ xbuf = x.data;
+
+ // Cache references to element accessors:
+ xget = x.accessors[ 0 ];
+ xset = x.accessors[ 1 ];
+
+ // Set the initial heap size:
+ n = N;
+
+ // Specify an initial "parent" index for building the heap:
+ parent = floor( N / 2 );
+
+ // Continue looping until the array is sorted...
+ while ( true ) {
+ if ( parent > 0 ) {
+ // We need to build the heap...
+ parent -= 1;
+ t = xget( xbuf, offsetX+(parent*strideX) );
+ } else {
+ // Reduce the heap size:
+ n -= 1;
+
+ // Check if the heap is empty, and, if so, we are finished sorting...
+ if ( n === 0 ) {
+ return x;
+ }
+ // Store the last heap value in a temporary variable in order to make room for the heap root being placed into its sorted position:
+ i = offsetX + (n*strideX);
+ t = xget( xbuf, i );
+
+ // Move the heap root to its sorted position:
+ xset( xbuf, i, xget( xbuf, offsetX ) );
+ }
+ // We need to "sift down", pushing `t` down the heap to in order to replace the parent and satisfy the heap property...
+
+ // Start at the parent index:
+ j = parent;
+
+ // Get the "left" child index:
+ child = (j*2) + 1;
+
+ while ( child < n ) {
+ // Find the largest child...
+ k = child + 1;
+ if ( k < n ) {
+ v1 = xget( xbuf, offsetX+(k*strideX) );
+ v2 = xget( xbuf, offsetX+(child*strideX) );
+
+ // Check if a "right" child exists and is "bigger"...
+ cmp = clbk.call( thisArg, v1, v2, x );
+ if ( cmp > 0 ) {
+ child += 1;
+ }
+ }
+ // Check if the largest child is bigger than `t`...
+ v1 = xget( xbuf, offsetX+(child*strideX) );
+ cmp = clbk.call( thisArg, v1, t, x );
+ if ( cmp > 0 ) {
+ // Insert the larger child value:
+ xset( xbuf, offsetX+(j*strideX), v1 );
+
+ // Update `j` to point to the child index:
+ j = child;
+
+ // Get the "left" child index and repeat...
+ child = (j*2) + 1;
+ } else {
+ // We've found `t`'s place in the heap...
+ break;
+ }
+ }
+ // Insert `t` into the heap:
+ xset( xbuf, offsetX+(j*strideX), t );
+ }
+}
+
+
+// EXPORTS //
+
+module.exports = gsorthpBy;
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/lib/index.js
new file mode 100644
index 000000000000..94681a2e52c6
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/lib/index.js
@@ -0,0 +1,77 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+/**
+* Sort a strided array using heapsort according to a provided callback function.
+*
+* @module @stdlib/blas/ext/base/gsorthp-by
+*
+* @example
+* var gsorthpBy = require( '@stdlib/blas/ext/base/gsorthp-by' );
+*
+* var x = [ 1.0, -2.0, 3.0, -4.0 ];
+*
+* function clbk( a, b ) {
+* if ( a < b ) {
+* return -1;
+* }
+* if ( a > b ) {
+* return 1;
+* }
+* return 0;
+* }
+*
+* gsorthpBy( x.length, x, 1, clbk );
+* // x => [ -4.0, -2.0, 1.0, 3.0 ]
+*
+* @example
+* var gsorthpBy = require( '@stdlib/blas/ext/base/gsorthp-by' );
+*
+* var x = [ 1.0, -2.0, 3.0, -4.0 ];
+*
+* function clbk( a, b ) {
+* if ( a < b ) {
+* return -1;
+* }
+* if ( a > b ) {
+* return 1;
+* }
+* return 0;
+* }
+*
+* gsorthpBy.ndarray( x.length, x, 1, 0, clbk );
+* // x => [ -4.0, -2.0, 1.0, 3.0 ]
+*/
+
+// MODULES //
+
+var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
+var main = require( './main.js' );
+var ndarray = require( './ndarray.js' );
+
+
+// MAIN //
+
+setReadOnly( main, 'ndarray', ndarray );
+
+
+// EXPORTS //
+
+module.exports = main;
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/lib/main.js
new file mode 100644
index 000000000000..c9c1f3b7f360
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/lib/main.js
@@ -0,0 +1,76 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var stride2offset = require( '@stdlib/strided/base/stride2offset' );
+var ndarray = require( './ndarray.js' );
+
+
+// MAIN //
+
+/**
+* Sorts a strided array using heapsort according to a provided callback function.
+*
+* ## Notes
+*
+* - This implementation uses an in-place algorithm derived from the work of Floyd (1964).
+*
+* ## References
+*
+* - Williams, John William Joseph. 1964. "Algorithm 232: Heapsort." _Communications of the ACM_ 7 (6). New York, NY, USA: Association for Computing Machinery: 347–49. doi:[10.1145/512274.512284](https://doi.org/10.1145/512274.512284).
+* - Floyd, Robert W. 1964. "Algorithm 245: Treesort." _Communications of the ACM_ 7 (12). New York, NY, USA: Association for Computing Machinery: 701. doi:[10.1145/355588.365103](https://doi.org/10.1145/355588.365103).
+*
+* @param {PositiveInteger} N - number of indexed elements
+* @param {NumericArray} x - input array
+* @param {integer} strideX - stride length
+* @param {Callback} clbk - callback function
+* @param {*} [thisArg] - execution context
+* @returns {NumericArray} input array
+*
+* @example
+* var x = [ 1.0, -2.0, 3.0, -4.0 ];
+*
+* function clbk( a, b ) {
+* if ( a < b ) {
+* return -1;
+* }
+* if ( a > b ) {
+* return 1;
+* }
+* return 0;
+* }
+*
+* gsorthpBy( x.length, x, 1, clbk );
+* // x => [ -4.0, -2.0, 1.0, 3.0 ]
+*/
+function gsorthpBy( N, x, strideX, clbk ) {
+ var thisArg;
+
+ if ( arguments.length > 4 ) {
+ thisArg = arguments[ 4 ];
+ }
+ return ndarray( N, x, strideX, stride2offset( N, strideX ), clbk, thisArg );
+}
+
+
+// EXPORTS //
+
+module.exports = gsorthpBy;
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/lib/ndarray.js
new file mode 100644
index 000000000000..d141e3ac4aac
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/lib/ndarray.js
@@ -0,0 +1,164 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var arraylike2object = require( '@stdlib/array/base/arraylike2object' );
+var floor = require( '@stdlib/math/base/special/floor' );
+var accessors = require( './accessors.js' );
+
+
+// MAIN //
+
+/**
+* Sorts a strided array using heapsort according to a provided callback function and using alternative indexing semantics.
+*
+* ## Notes
+*
+* - This implementation uses an in-place algorithm derived from the work of Floyd (1964).
+*
+* ## References
+*
+* - Williams, John William Joseph. 1964. "Algorithm 232: Heapsort." _Communications of the ACM_ 7 (6). New York, NY, USA: Association for Computing Machinery: 347–49. doi:[10.1145/512274.512284](https://doi.org/10.1145/512274.512284).
+* - Floyd, Robert W. 1964. "Algorithm 245: Treesort." _Communications of the ACM_ 7 (12). New York, NY, USA: Association for Computing Machinery: 701. doi:[10.1145/355588.365103](https://doi.org/10.1145/355588.365103).
+*
+* @param {PositiveInteger} N - number of indexed elements
+* @param {NumericArray} x - input array
+* @param {integer} strideX - stride length
+* @param {NonNegativeInteger} offsetX - starting index
+* @param {Callback} clbk - callback function
+* @param {*} [thisArg] - execution context
+* @returns {NumericArray} input array
+*
+* @example
+* var x = [ 1.0, -2.0, 3.0, -4.0 ];
+*
+* function clbk( a, b ) {
+* if ( a < b ) {
+* return -1;
+* }
+* if ( a > b ) {
+* return 1;
+* }
+* return 0;
+* }
+*
+* gsorthpBy( x.length, x, 1, 0, clbk );
+* // x => [ -4.0, -2.0, 1.0, 3.0 ]
+*/
+function gsorthpBy( N, x, strideX, offsetX, clbk ) {
+ var thisArg;
+ var parent;
+ var child;
+ var cmp;
+ var v1;
+ var v2;
+ var ox;
+ var n;
+ var t;
+ var i;
+ var j;
+ var k;
+
+ if ( arguments.length > 5 ) {
+ thisArg = arguments[ 5 ];
+ }
+ if ( N <= 0 ) {
+ return x;
+ }
+ ox = arraylike2object( x );
+ if ( ox.accessorProtocol ) {
+ accessors( N, ox, strideX, offsetX, clbk, thisArg );
+ return ox.data;
+ }
+ // Set the initial heap size:
+ n = N;
+
+ // Specify an initial "parent" index for building the heap:
+ parent = floor( N / 2 );
+
+ // Continue looping until the array is sorted...
+ while ( true ) {
+ if ( parent > 0 ) {
+ // We need to build the heap...
+ parent -= 1;
+ t = x[ offsetX+(parent*strideX) ];
+ } else {
+ // Reduce the heap size:
+ n -= 1;
+
+ // Check if the heap is empty, and, if so, we are finished sorting...
+ if ( n === 0 ) {
+ return x;
+ }
+ // Store the last heap value in a temporary variable in order to make room for the heap root being placed into its sorted position:
+ i = offsetX + (n*strideX);
+ t = x[ i ];
+
+ // Move the heap root to its sorted position:
+ x[ i ] = x[ offsetX ];
+ }
+ // We need to "sift down", pushing `t` down the heap to in order to replace the parent and satisfy the heap property...
+
+ // Start at the parent index:
+ j = parent;
+
+ // Get the "left" child index:
+ child = (j*2) + 1;
+
+ while ( child < n ) {
+ // Find the largest child...
+ k = child + 1;
+ if ( k < n ) {
+ v1 = x[ offsetX+(k*strideX) ];
+ v2 = x[ offsetX+(child*strideX) ];
+
+ // Check if a "right" child exists and is "bigger"...
+ cmp = clbk.call( thisArg, v1, v2, x );
+ if ( cmp > 0 ) {
+ child += 1;
+ }
+ }
+ // Check if the largest child is bigger than `t`...
+ v1 = x[ offsetX+(child*strideX) ];
+ cmp = clbk.call( thisArg, v1, t, x );
+ if ( cmp > 0 ) {
+ // Insert the larger child value:
+ x[ offsetX+(j*strideX) ] = v1;
+
+ // Update `j` to point to the child index:
+ j = child;
+
+ // Get the "left" child index and repeat...
+ child = (j*2) + 1;
+ } else {
+ // We've found `t`'s place in the heap...
+ break;
+ }
+ }
+ // Insert `t` into the heap:
+ x[ offsetX+(j*strideX) ] = t;
+ }
+}
+
+
+// EXPORTS //
+
+module.exports = gsorthpBy;
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/package.json b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/package.json
new file mode 100644
index 000000000000..37f68be3d99c
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/package.json
@@ -0,0 +1,71 @@
+{
+ "name": "@stdlib/blas/ext/base/gsorthp-by",
+ "version": "0.0.0",
+ "description": "Sort a strided array using heapsort according to a provided callback function.",
+ "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",
+ "mathematics",
+ "math",
+ "blas",
+ "extended",
+ "sort",
+ "order",
+ "arrange",
+ "permute",
+ "heap",
+ "heapsort",
+ "callback",
+ "comparator",
+ "strided",
+ "array",
+ "ndarray"
+ ],
+ "__stdlib__": {}
+}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/test/test.js
new file mode 100644
index 000000000000..f5d3f513a80b
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/test/test.js
@@ -0,0 +1,38 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var tape = require( 'tape' );
+var gsorthpBy = require( './../lib' );
+
+
+// TESTS //
+
+tape( 'main export is a function', function test( t ) {
+ t.ok( true, __filename );
+ t.strictEqual( typeof gsorthpBy, 'function', 'main export is a function' );
+ t.end();
+});
+
+tape( 'attached to the main export is a method providing an ndarray interface', function test( t ) {
+ t.strictEqual( typeof gsorthpBy.ndarray, 'function', 'method is a function' );
+ t.end();
+});
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/test/test.main.js
new file mode 100644
index 000000000000..cc8f45036798
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/test/test.main.js
@@ -0,0 +1,417 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var tape = require( 'tape' );
+var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
+var Float64Array = require( '@stdlib/array/float64' );
+var gsorthpBy = require( './../lib' );
+
+
+// TESTS //
+
+tape( 'main export is a function', function test( t ) {
+ t.ok( true, __filename );
+ t.strictEqual( typeof gsorthpBy, 'function', 'main export is a function' );
+ t.end();
+});
+
+tape( 'the function has an arity of 4', function test( t ) {
+ t.strictEqual( gsorthpBy.length, 4, 'has expected arity' );
+ t.end();
+});
+
+tape( 'the function sorts a strided array', function test( t ) {
+ var expected;
+ var x;
+
+ x = [ 10.0, -1.0, 3.0, 50.0, 10.0, -4.0, 8.0 ];
+ expected = [ 50.0, 10.0, 10.0, 8.0, 3.0, -1.0, -4.0 ];
+
+ gsorthpBy( 7, x, 1, clbk1 );
+ t.deepEqual( x, expected, 'returns expected value' );
+
+ x = [ 10.0, -1.0, 3.0, 50.0, 10.0, -4.0, 8.0 ];
+ expected = [ -4.0, -1.0, 3.0, 8.0, 10.0, 10.0, 50.0 ];
+
+ gsorthpBy( 7, x, 1, clbk2 );
+ t.deepEqual( x, expected, 'returns expected value' );
+
+ t.end();
+
+ function clbk1( a, b ) {
+ if ( a > b ) {
+ return -1;
+ }
+ if ( a < b ) {
+ return 1;
+ }
+ return 0;
+ }
+
+ function clbk2( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'the function sorts a strided array (accessors)', function test( t ) {
+ var expected;
+ var x;
+
+ x = [ 10.0, -1.0, 3.0, 50.0, 10.0, -4.0, 8.0 ];
+ expected = [ 50.0, 10.0, 10.0, 8.0, 3.0, -1.0, -4.0 ];
+
+ gsorthpBy( 7, toAccessorArray( x ), 1, clbk1 );
+ t.deepEqual( x, expected, 'returns expected value' );
+
+ x = [ 10.0, -1.0, 3.0, 50.0, 10.0, -4.0, 8.0 ];
+ expected = [ -4.0, -1.0, 3.0, 8.0, 10.0, 10.0, 50.0 ];
+
+ gsorthpBy( 7, toAccessorArray( x ), 1, clbk2 );
+ t.deepEqual( x, expected, 'returns expected value' );
+
+ t.end();
+
+ function clbk1( a, b ) {
+ if ( a > b ) {
+ return -1;
+ }
+ if ( a < b ) {
+ return 1;
+ }
+ return 0;
+ }
+
+ function clbk2( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'the function returns a reference to the input array', function test( t ) {
+ var out;
+ var x;
+
+ x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];
+ out = gsorthpBy( x.length, x, 1, clbk );
+
+ t.strictEqual( out, x, 'same reference' );
+ t.end();
+
+ function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'the function returns a reference to the input array (accessors)', function test( t ) {
+ var out;
+ var x;
+
+ x = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
+ out = gsorthpBy( x.length, x, 1, clbk );
+
+ t.strictEqual( out, x, 'same reference' );
+ t.end();
+
+ function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `x` unchanged', function test( t ) {
+ var expected;
+ var x;
+
+ x = [ 3.0, -4.0, 1.0 ];
+ expected = [ 3.0, -4.0, 1.0 ];
+
+ gsorthpBy( 0, x, 1, clbk );
+ t.deepEqual( x, expected, 'returns expected value' );
+
+ gsorthpBy( -4, x, 1, clbk );
+ t.deepEqual( x, expected, 'returns expected value' );
+
+ t.end();
+
+ function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'the function supports specifying a stride', function test( t ) {
+ var expected;
+ var x;
+
+ x = [
+ 2.0, // 0
+ -3.0,
+ -5.0, // 1
+ 7.0,
+ 6.0 // 2
+ ];
+ expected = [
+ -5.0, // 0
+ -3.0,
+ 2.0, // 1
+ 7.0,
+ 6.0 // 2
+ ];
+
+ gsorthpBy( 3, x, 2, clbk );
+ t.deepEqual( x, expected, 'returns expected value' );
+ t.end();
+
+ function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'the function supports specifying a stride (accessors)', function test( t ) {
+ var expected;
+ var x;
+
+ x = [
+ 2.0, // 0
+ -3.0,
+ -5.0, // 1
+ 7.0,
+ 6.0 // 2
+ ];
+ expected = [
+ -5.0, // 0
+ -3.0,
+ 2.0, // 1
+ 7.0,
+ 6.0 // 2
+ ];
+
+ gsorthpBy( 3, toAccessorArray( x ), 2, clbk );
+ t.deepEqual( x, expected, 'returns expected value' );
+ t.end();
+
+ function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'the function supports specifying a negative stride', function test( t ) {
+ var expected;
+ var x;
+
+ x = [
+ 2.0, // 2
+ -3.0,
+ -5.0, // 1
+ 7.0,
+ 6.0 // 0
+ ];
+ expected = [
+ 6.0, // 2
+ -3.0,
+ 2.0, // 1
+ 7.0,
+ -5.0 // 0
+ ];
+
+ gsorthpBy( 3, x, -2, clbk );
+ t.deepEqual( x, expected, 'returns expected value' );
+ t.end();
+
+ function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'the function supports specifying a negative stride (accessors)', function test( t ) {
+ var expected;
+ var x;
+
+ x = [
+ 2.0, // 2
+ -3.0,
+ -5.0, // 1
+ 7.0,
+ 6.0 // 0
+ ];
+ expected = [
+ 6.0, // 2
+ -3.0,
+ 2.0, // 1
+ 7.0,
+ -5.0 // 0
+ ];
+
+ gsorthpBy( 3, toAccessorArray( x ), -2, clbk );
+ t.deepEqual( x, expected, 'returns expected value' );
+ t.end();
+
+ function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'the function supports view offsets', function test( t ) {
+ var expected;
+ var x0;
+ var x1;
+
+ x0 = new Float64Array([
+ 1.0,
+ -2.0, // 0
+ 3.0,
+ -4.0, // 1
+ 5.0,
+ -6.0 // 2
+ ]);
+ expected = new Float64Array([
+ 1.0,
+ -6.0, // 0
+ 3.0,
+ -4.0, // 1
+ 5.0,
+ -2.0 // 2
+ ]);
+
+ x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
+
+ gsorthpBy( 3, x1, 2, clbk );
+ t.deepEqual( x0, expected, 'returns expected value' );
+ t.end();
+
+ function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'the function supports providing a callback execution context', function test( t ) {
+ var expected;
+ var ctx;
+ var x;
+
+ ctx = {
+ 'count': 0
+ };
+ x = [ 10.0, -1.0, 3.0, 50.0 ];
+ expected = [ 50.0, 10.0, 3.0, -1.0 ];
+
+ gsorthpBy( 4, x, 1, clbk, ctx );
+ t.deepEqual( x, expected, 'returns expected value' );
+ t.strictEqual( ctx.count > 0, true, 'context was used' );
+ t.end();
+
+ function clbk( a, b ) {
+ this.count += 1; // eslint-disable-line no-invalid-this
+ if ( a > b ) {
+ return -1;
+ }
+ if ( a < b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'the function supports providing a callback execution context (accessors)', function test( t ) {
+ var expected;
+ var ctx;
+ var x;
+
+ ctx = {
+ 'count': 0
+ };
+ x = [ 10.0, -1.0, 3.0, 50.0 ];
+ expected = [ 50.0, 10.0, 3.0, -1.0 ];
+
+ gsorthpBy( 4, toAccessorArray( x ), 1, clbk, ctx );
+ t.deepEqual( x, expected, 'returns expected value' );
+ t.strictEqual( ctx.count > 0, true, 'context was used' );
+ t.end();
+
+ function clbk( a, b ) {
+ this.count += 1; // eslint-disable-line no-invalid-this
+ if ( a > b ) {
+ return -1;
+ }
+ if ( a < b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
diff --git a/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/test/test.ndarray.js
new file mode 100644
index 000000000000..260708383e25
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/gsorthp-by/test/test.ndarray.js
@@ -0,0 +1,493 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2026 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var tape = require( 'tape' );
+var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
+var gsorthpBy = require( './../lib/ndarray.js' );
+
+
+// TESTS //
+
+tape( 'main export is a function', function test( t ) {
+ t.ok( true, __filename );
+ t.strictEqual( typeof gsorthpBy, 'function', 'main export is a function' );
+ t.end();
+});
+
+tape( 'the function has an arity of 5', function test( t ) {
+ t.strictEqual( gsorthpBy.length, 5, 'has expected arity' );
+ t.end();
+});
+
+tape( 'the function sorts a strided array', function test( t ) {
+ var expected;
+ var x;
+
+ x = [ 10.0, -1.0, 3.0, 50.0, 10.0, -4.0, 8.0 ];
+ expected = [ 50.0, 10.0, 10.0, 8.0, 3.0, -1.0, -4.0 ];
+
+ gsorthpBy( 7, x, 1, 0, clbk1 );
+ t.deepEqual( x, expected, 'returns expected value' );
+
+ x = [ 10.0, -1.0, 3.0, 50.0, 10.0, -4.0, 8.0 ];
+ expected = [ -4.0, -1.0, 3.0, 8.0, 10.0, 10.0, 50.0 ];
+
+ gsorthpBy( 7, x, 1, 0, clbk2 );
+ t.deepEqual( x, expected, 'returns expected value' );
+
+ t.end();
+
+ function clbk1( a, b ) {
+ if ( a > b ) {
+ return -1;
+ }
+ if ( a < b ) {
+ return 1;
+ }
+ return 0;
+ }
+
+ function clbk2( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'the function sorts a strided array (accessors)', function test( t ) {
+ var expected;
+ var x;
+
+ x = [ 10.0, -1.0, 3.0, 50.0, 10.0, -4.0, 8.0 ];
+ expected = [ 50.0, 10.0, 10.0, 8.0, 3.0, -1.0, -4.0 ];
+
+ gsorthpBy( 7, toAccessorArray( x ), 1, 0, clbk1 );
+ t.deepEqual( x, expected, 'returns expected value' );
+
+ x = [ 10.0, -1.0, 3.0, 50.0, 10.0, -4.0, 8.0 ];
+ expected = [ -4.0, -1.0, 3.0, 8.0, 10.0, 10.0, 50.0 ];
+
+ gsorthpBy( 7, toAccessorArray( x ), 1, 0, clbk2 );
+ t.deepEqual( x, expected, 'returns expected value' );
+
+ t.end();
+
+ function clbk1( a, b ) {
+ if ( a > b ) {
+ return -1;
+ }
+ if ( a < b ) {
+ return 1;
+ }
+ return 0;
+ }
+
+ function clbk2( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'the function returns a reference to the input array', function test( t ) {
+ var out;
+ var x;
+
+ x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ];
+ out = gsorthpBy( x.length, x, 1, 0, clbk );
+
+ t.strictEqual( out, x, 'same reference' );
+ t.end();
+
+ function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'the function returns a reference to the input array (accessors)', function test( t ) {
+ var out;
+ var x;
+
+ x = toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
+ out = gsorthpBy( x.length, x, 1, 0, clbk );
+
+ t.strictEqual( out, x, 'same reference' );
+ t.end();
+
+ function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `x` unchanged', function test( t ) {
+ var expected;
+ var x;
+
+ x = [ 3.0, -4.0, 1.0 ];
+ expected = [ 3.0, -4.0, 1.0 ];
+
+ gsorthpBy( 0, x, 1, 0, clbk );
+ t.deepEqual( x, expected, 'returns expected value' );
+
+ gsorthpBy( -4, x, 1, 0, clbk );
+ t.deepEqual( x, expected, 'returns expected value' );
+
+ t.end();
+
+ function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'the function supports specifying an offset', function test( t ) {
+ var expected;
+ var x;
+
+ x = [
+ 1.0,
+ -2.0, // 0
+ 3.0,
+ -4.0, // 1
+ 5.0,
+ -6.0 // 2
+ ];
+ expected = [
+ 1.0,
+ -6.0, // 0
+ 3.0,
+ -4.0, // 1
+ 5.0,
+ -2.0 // 2
+ ];
+
+ gsorthpBy( 3, x, 2, 1, clbk );
+ t.deepEqual( x, expected, 'returns expected value' );
+ t.end();
+
+ function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'the function supports specifying an offset', function test( t ) {
+ var expected;
+ var x;
+
+ x = [ 1.0, -2.0, 3.0, -4.0, 5.0 ];
+ expected = [ 1.0, -4.0, -2.0, 3.0, 5.0 ];
+
+ gsorthpBy( 4, x, 1, 1, clbk );
+ t.deepEqual( x, expected, 'returns expected value' );
+ t.end();
+
+ function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'the function supports specifying an offset (accessors)', function test( t ) {
+ var expected;
+ var x;
+
+ x = [ 1.0, -2.0, 3.0, -4.0, 5.0 ];
+ expected = [ 1.0, -4.0, -2.0, 3.0, 5.0 ];
+
+ gsorthpBy( 4, toAccessorArray( x ), 1, 1, clbk );
+ t.deepEqual( x, expected, 'returns expected value' );
+ t.end();
+
+ function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'the function supports specifying an offset (accessors)', function test( t ) {
+ var expected;
+ var x;
+
+ x = [
+ 1.0,
+ -2.0, // 0
+ 3.0,
+ -4.0, // 1
+ 5.0,
+ -6.0 // 2
+ ];
+ expected = [
+ 1.0,
+ -6.0, // 0
+ 3.0,
+ -4.0, // 1
+ 5.0,
+ -2.0 // 2
+ ];
+
+ gsorthpBy( 3, toAccessorArray( x ), 2, 1, clbk );
+ t.deepEqual( x, expected, 'returns expected value' );
+ t.end();
+
+ function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'the function supports specifying a stride', function test( t ) {
+ var expected;
+ var x;
+
+ x = [
+ 2.0, // 0
+ -3.0,
+ -5.0, // 1
+ 7.0,
+ 6.0 // 2
+ ];
+ expected = [
+ -5.0, // 0
+ -3.0,
+ 2.0, // 1
+ 7.0,
+ 6.0 // 2
+ ];
+
+ gsorthpBy( 3, x, 2, 0, clbk );
+ t.deepEqual( x, expected, 'returns expected value' );
+ t.end();
+
+ function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'the function supports specifying a stride (accessors)', function test( t ) {
+ var expected;
+ var x;
+
+ x = [
+ 2.0, // 0
+ -3.0,
+ -5.0, // 1
+ 7.0,
+ 6.0 // 2
+ ];
+ expected = [
+ -5.0, // 0
+ -3.0,
+ 2.0, // 1
+ 7.0,
+ 6.0 // 2
+ ];
+
+ gsorthpBy( 3, toAccessorArray( x ), 2, 0, clbk );
+ t.deepEqual( x, expected, 'returns expected value' );
+ t.end();
+
+ function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'the function supports specifying a negative stride', function test( t ) {
+ var expected;
+ var x;
+
+ x = [
+ 2.0, // 2
+ -3.0,
+ -5.0, // 1
+ 7.0,
+ 6.0 // 0
+ ];
+ expected = [
+ 6.0, // 2
+ -3.0,
+ 2.0, // 1
+ 7.0,
+ -5.0 // 0
+ ];
+
+ gsorthpBy( 3, x, -2, 4, clbk );
+ t.deepEqual( x, expected, 'returns expected value' );
+ t.end();
+
+ function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'the function supports specifying a negative stride (accessors)', function test( t ) {
+ var expected;
+ var x;
+
+ x = [
+ 2.0, // 2
+ -3.0,
+ -5.0, // 1
+ 7.0,
+ 6.0 // 0
+ ];
+ expected = [
+ 6.0, // 2
+ -3.0,
+ 2.0, // 1
+ 7.0,
+ -5.0 // 0
+ ];
+
+ gsorthpBy( 3, toAccessorArray( x ), -2, 4, clbk );
+ t.deepEqual( x, expected, 'returns expected value' );
+ t.end();
+
+ function clbk( a, b ) {
+ if ( a < b ) {
+ return -1;
+ }
+ if ( a > b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'the function supports providing a callback execution context', function test( t ) {
+ var expected;
+ var ctx;
+ var x;
+
+ ctx = {
+ 'count': 0
+ };
+ x = [ 10.0, -1.0, 3.0, 50.0 ];
+ expected = [ 50.0, 10.0, 3.0, -1.0 ];
+
+ gsorthpBy( 4, x, 1, 0, clbk, ctx );
+ t.deepEqual( x, expected, 'returns expected value' );
+ t.strictEqual( ctx.count > 0, true, 'context was used' );
+ t.end();
+
+ function clbk( a, b ) {
+ this.count += 1; // eslint-disable-line no-invalid-this
+ if ( a > b ) {
+ return -1;
+ }
+ if ( a < b ) {
+ return 1;
+ }
+ return 0;
+ }
+});
+
+tape( 'the function supports providing a callback execution context (accessors)', function test( t ) {
+ var expected;
+ var ctx;
+ var x;
+
+ ctx = {
+ 'count': 0
+ };
+ x = [ 10.0, -1.0, 3.0, 50.0 ];
+ expected = [ 50.0, 10.0, 3.0, -1.0 ];
+
+ gsorthpBy( 4, toAccessorArray( x ), 1, 0, clbk, ctx );
+ t.deepEqual( x, expected, 'returns expected value' );
+ t.strictEqual( ctx.count > 0, true, 'context was used' );
+ t.end();
+
+ function clbk( a, b ) {
+ this.count += 1; // eslint-disable-line no-invalid-this
+ if ( a > b ) {
+ return -1;
+ }
+ if ( a < b ) {
+ return 1;
+ }
+ return 0;
+ }
+});