Home Manual Reference Source

Overview

Installation

Can be managed using jspm or npm.

jspm

jspm install npm:@comparison-sorting/partition

npm

npm install @comparison-sorting/partition --save

Usage

The code needs a ES2015+ polyfill to work, for example regenerator-runtime/runtime.

await import( 'regenerator-runtime/runtime.js' ) ;
// or
import 'regenerator-runtime/runtime.js' ;

Then

const measure = await import( '@comparison-sorting/partition' ) ;
// or
import measure from '@comparison-sorting/partition' ;

Examples

import {increasing} from '@total-order/primitive';
import * as partition from '@comparison-sorting/partition';

/** hoare partitioning */
let array = [ 3 , 4 , 1 , 9 , 0 ];
let pivot = partition.hoare( increasing , array , 0 , array.length );
pivot ; // 2
array ; // [ 1 , 0 , 3 , 9 , 4 ]

// but also

/** lomuto partitioning */
partition.lomuto ;
/** yaroslavskiy (two pivots) */
partition.yaroslavskiy ;