Noncommital Premarital Mischief

    @aureooms/js-mergesort

    7.1.0 • Public • Published

    js-mergesort

    Mergesort code bricks for JavaScript. Parent is aureooms/js-sort.

    let sort = mergesort.recursive( merging.tapemerge , array.copy ) ;

    NPM license NPM version Bower version Build Status Coverage Status Dependencies Status devDependencies Status Code Climate NPM downloads per month GitHub issues Inline docs

    Can be managed through jspm, duo, component, bower, ender, jam, spm, and npm.

    Install

    jspm

    jspm install github:aureooms/js-mergesort
    # or
    jspm install npm:@aureooms/js-mergesort
    

    duo

    No install step needed for duo!

    component

    component install aureooms/js-mergesort
    

    bower

    bower install @aureooms/js-mergesort
    

    ender

    ender add @aureooms/js-mergesort
    

    jam

    jam install @aureooms/js-mergesort
    

    spm

    spm install @aureooms/js-mergesort --save
    

    npm

    npm install @aureooms/js-mergesort --save
    

    Require

    jspm

    let mergesort = require( "github:aureooms/js-mergesort" ) ;
    // or
    import mergesort from '@aureooms/js-mergesort' ;

    duo

    let mergesort = require( "aureooms/js-mergesort" ) ;

    component, ender, spm, npm

    let mergesort = require( "@aureooms/js-mergesort" ) ;

    bower

    The script tag exposes the global variable mergesort.

    <script src="bower_components/@aureooms/js-mergesort/js/dist/mergesort.min.js"></script>

    Alternatively, you can use any tool mentioned here.

    jam

    require( [ "@aureooms/js-mergesort" ] , function ( mergesort ) { ... } ) ;

    Use

    let array = require( "@aureooms/js-array" ) ;
    let compare = require( "@aureooms/js-compare" ) ;
    let merging = require( "@aureooms/js-merging" ) ;
    
    /** recursive mergesort */
    let sort = mergesort.recursive( merging.tapemerge , array.copy ) ;
    
    /** iterative mergesort */
    let sort = mergesort.iterative( merging.tapemerge , array.copy ) ;
    
    // for example
    
    let random = require( "@aureooms/js-random" ) ;
    
    let n = 10 ;
    let A = array.alloc( n ) ;
    let B = array.alloc( n ) ;
    
    array.iota( A , 0 , n , 0 ) ;
    
    A ; // [ 0 , 1 , ... , 9 ]
    
    random.shuffle( A , 0 , n ) ;
    
    sort( compare.increasing , A , 0 , n , B , 0 , n ) ;
    
    B ; // [ 0 , 1 , ... , 9 ]
    
    // or decreasing
    
    random.shuffle( A , 0 , n ) ;
    
    sort( compare.decreasing , A , 0 , n , B , 0 , n ) ;
    
    B ; // [ 9 , 8 , ... , 0 ]

    Reference

    Install

    npm i @aureooms/js-mergesort

    DownloadsWeekly Downloads

    1

    Version

    7.1.0

    License

    AGPL-3.0

    Last publish

    Collaborators

    • aureooms