Skip to content

Commit 1468962

Browse files
docs: add sort method documentation
1 parent 08d6ad7 commit 1468962

File tree

1 file changed

+33
-0
lines changed
  • lib/node_modules/@stdlib/array/fixed-endian-factory

1 file changed

+33
-0
lines changed

lib/node_modules/@stdlib/array/fixed-endian-factory/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,39 @@ var v = arr.get( 100 );
483483
// returns undefined
484484
```
485485

486+
<a name="method-sort"></a>
487+
488+
#### TypedArrayFE.prototype.sort( compareFcn )
489+
490+
Sorts an array in-place.
491+
492+
```javascript
493+
function compareFcn( a, b ) {
494+
if ( a > b ) {
495+
return 1;
496+
}
497+
if ( a < b ) {
498+
return -1;
499+
}
500+
return 0;
501+
}
502+
var Float64ArrayFE = fixedEndianFactory( 'float64' );
503+
var arr = new Float64ArrayFE( 'little-endian', [ 3.0, 1.0, 2.0 ] );
504+
// returns <Float64ArrayFE>
505+
506+
var out=arr.sort( compareFcn );
507+
// returns <Float64ArrayFE>
508+
509+
var v=out.get(0);
510+
// returns 1.0
511+
512+
v=out.get(1);
513+
// returns 2.0
514+
515+
v=out.get(2);
516+
// returns 3.0
517+
```
518+
486519
<a name="method-index-of"></a>
487520

488521
#### TypedArrayFE.prototype.indexOf( searchElement\[, fromIndex] )

0 commit comments

Comments
 (0)