Skip to content

Commit bb097df

Browse files
docs: add documentation for toSorted method
1 parent b79d687 commit bb097df

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
@@ -515,6 +515,39 @@ var idx = arr.indexOf( 5.0 );
515515
// returns -1
516516
```
517517

518+
<a name="method-toSorted"></a>
519+
520+
#### TypedArrayFE.prototype.toSorted( compareFcn )
521+
522+
Returns a new typed array containing the elements in sorted order.
523+
524+
```javascript
525+
function compareFcn( a, b ) {
526+
if ( a > b ) {
527+
return 1;
528+
}
529+
if ( a < b ) {
530+
return -1;
531+
}
532+
return 0;
533+
}
534+
var Float64ArrayFE = fixedEndianFactory( 'float64' );
535+
var arr = new Float64ArrayFE( 'little-endian', [ 3.0, 1.0, 2.0 ] );
536+
// returns <Float64ArrayFE>
537+
538+
var out=arr.toSorted( compareFcn );
539+
// returns <Float64ArrayFE>
540+
541+
var v=out.get(0);
542+
// returns 1.0
543+
544+
v=out.get(1);
545+
// returns 2.0
546+
547+
v=out.get(2);
548+
// returns 3.0
549+
```
550+
518551
<a name="method-map"></a>
519552

520553
#### TypedArray.prototype.map( callbackFn\[, thisArg] )

0 commit comments

Comments
 (0)