You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Sorts an input ndarray along one or more ndarray dimensions.
369
+
*
370
+
* ## Notes
371
+
*
372
+
* - The input ndarray is sorted **in-place** (i.e., the input ndarray is **mutated**).
373
+
* - If `sortOrder < 0.0` or is either `'desc'` or `'descending'`, the input ndarray is sorted in **decreasing** order. If `sortOrder > 0.0` or is either `'asc'` or `'ascending'`, the input ndarray is sorted in **increasing** order. If `sortOrder == 0.0`, the input ndarray is left unchanged.
374
+
* - The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`.
375
+
* - The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first.
376
+
*
377
+
* @param x - input ndarray
378
+
* @param sortOrder - sort order
379
+
* @param options - function options
380
+
* @returns output ndarray
381
+
*
382
+
* @example
383
+
* var array = require( '@stdlib/ndarray/array' );
384
+
*
385
+
* var x = array( [ -1.0, 2.0, -3.0 ] );
386
+
*
387
+
* var y = ns.sort( x, 1.0 );
388
+
* // returns <ndarray>[ -3.0, -1.0, 2.0 ]
389
+
*
390
+
* @example
391
+
* var array = require( '@stdlib/ndarray/array' );
392
+
*
393
+
* var x = array( [ -1.0, 2.0, -3.0 ] );
394
+
*
395
+
* var y = ns.sort( x, 1.0 );
396
+
* // returns <ndarray>[ -3.0, -1.0, 2.0 ]
397
+
*/
398
+
sort: typeofsort;
399
+
356
400
/**
357
401
* Sorts an input ndarray along one or more ndarray dimensions using heapsort.
358
402
*
@@ -371,28 +415,20 @@ interface Namespace {
371
415
* @returns output ndarray
372
416
*
373
417
* @example
374
-
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
375
418
* var array = require( '@stdlib/ndarray/array' );
376
419
*
377
420
* var x = array( [ -1.0, 2.0, -3.0 ] );
378
421
*
379
422
* var y = ns.sorthp( x, 1.0 );
380
-
* // returns <ndarray>
381
-
*
382
-
* var arr = ndarray2array( y );
383
-
* // returns [ -3.0, -1.0, 2.0 ]
423
+
* // returns <ndarray>[ -3.0, -1.0, 2.0 ]
384
424
*
385
425
* @example
386
-
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
387
426
* var array = require( '@stdlib/ndarray/array' );
388
427
*
389
428
* var x = array( [ -1.0, 2.0, -3.0 ] );
390
429
*
391
430
* var y = ns.sorthp( x, 1.0 );
392
-
* // returns <ndarray>
393
-
*
394
-
* var arr = ndarray2array( y );
395
-
* // returns [ -3.0, -1.0, 2.0 ]
431
+
* // returns <ndarray>[ -3.0, -1.0, 2.0 ]
396
432
*/
397
433
sorthp: typeofsorthp;
398
434
@@ -409,10 +445,7 @@ interface Namespace {
409
445
* var x = array( [ -1.0, 2.0, -3.0 ] );
410
446
*
411
447
* var y = ns.sum( x );
412
-
* // returns <ndarray>
413
-
*
414
-
* var v = y.get();
415
-
* // returns -2.0
448
+
* // returns <ndarray>[ -2.0 ]
416
449
*
417
450
* @example
418
451
* var array = require( '@stdlib/ndarray/array' );
@@ -422,16 +455,54 @@ interface Namespace {
422
455
* var y = zeros( [] );
423
456
*
424
457
* var out = ns.sum.assign( x, y );
425
-
* // returns <ndarray>
426
-
*
427
-
* var v = out.get();
428
-
* // returns -2.0
458
+
* // returns <ndarray>[ -2.0 ]
429
459
*
430
460
* var bool = ( out === y );
431
461
* // returns true
432
462
*/
433
463
sum: typeofsum;
434
464
465
+
/**
466
+
* Returns a new ndarray with the elements of an input ndarray sorted along one or more ndarray dimensions.
467
+
*
468
+
* ## Notes
469
+
*
470
+
* - If `sortOrder < 0.0` or is either `'desc'` or `'descending'`, the input ndarray is sorted in **decreasing** order. If `sortOrder > 0.0` or is either `'asc'` or `'ascending'`, the input ndarray is sorted in **increasing** order. If `sortOrder == 0.0`, the input ndarray is left unchanged.
471
+
* - The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`.
472
+
* - The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first.
* Returns a new ndarray with the elements of an input ndarray sorted along one or more ndarray dimensions using heapsort.
437
508
*
@@ -449,19 +520,14 @@ interface Namespace {
449
520
* @returns output ndarray
450
521
*
451
522
* @example
452
-
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
453
523
* var array = require( '@stdlib/ndarray/array' );
454
524
*
455
525
* var x = array( [ -1.0, 2.0, -3.0 ] );
456
526
*
457
527
* var y = ns.toSortedhp( x, 1.0 );
458
-
* // returns <ndarray>
459
-
*
460
-
* var arr = ndarray2array( y );
461
-
* // returns [ -3.0, -1.0, 2.0 ]
528
+
* // returns <ndarray>[ -3.0, -1.0, 2.0 ]
462
529
*
463
530
* @example
464
-
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
465
531
* var zeros = require( '@stdlib/ndarray/zeros' );
466
532
* var array = require( '@stdlib/ndarray/array' );
467
533
*
@@ -470,16 +536,39 @@ interface Namespace {
470
536
* var y = zeros( [ 3 ] );
471
537
*
472
538
* var out = ns.toSortedhp.assign( x, y );
473
-
* // returns <ndarray>
474
-
*
475
-
* var arr = ndarray2array( out );
476
-
* // returns [ -3.0, -1.0, 2.0 ]
539
+
* // returns <ndarray>[ -3.0, -1.0, 2.0 ]
477
540
*
478
541
* var bool = ( out === y );
479
542
* // returns true
480
543
*/
481
544
toSortedhp: typeoftoSortedhp;
482
545
546
+
/**
547
+
* Returns a new ndarray filled with linearly spaced numeric elements which increment by 1 starting from a specified value along one or more ndarray dimensions.
0 commit comments