Skip to content

Commit b683fae

Browse files
♻️ refactor: Only keep Ford-Johnson algorithm implementation.
1 parent 52fcf6c commit b683fae

20 files changed

+60
-315
lines changed

.esdoc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"autoPrivate": true
3636
},
3737
"brand": {
38-
"title": "@aureooms/js-sort"
38+
"title": "@aureooms/js-merge-insertion-sort"
3939
},
4040
"test": {
4141
"type": "ava",

README.md

Lines changed: 23 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,31 @@
1-
:signal_strength: [@aureooms/js-sort](https://aureooms.github.io/js-sort)
1+
:person_fencing: [@aureooms/js-merge-insertion-sort](https://aureooms.github.io/js-merge-insertion-sort)
22
==
33

44
<img src="http://www.explainxkcd.com//wiki/images/b/bc/ineffective_sorts.png" width="864">
55

6-
Sorting algorithms for JavaScript.
7-
See [docs](https://aureooms.github.io/js-sort).
8-
Parent is [@aureooms/js-algorithms](https://github.com/aureooms/js-algorithms).
9-
10-
> :building_construction: Caveat emptor! This is work in progress. Code may be
11-
> working. Documentation may be present. Coherence may be. Maybe.
6+
[Ford-Johnson algorithm](https://en.wikipedia.org/wiki/Merge-insertion_sort) for JavaScript.
7+
See [docs](https://aureooms.github.io/js-merge-insertion-sort).
8+
Parent is [@aureooms/js-sort](https://github.com/aureooms/js-sort).
129

1310
```js
14-
let fordjohnson = sort._fordjohnson( search.binarysearch ) ;
11+
import { fordjohnson } from "@aureooms/js-merge-insertion-sort" ;
12+
import { binarysearch } from "@aureooms/js-search" ;
13+
import { swap } from "@aureooms/js-array" ;
14+
const fj = fordjohnson( binarysearch ) ;
15+
const sort = (compare, a, i, j) => fj(compare, swap, a, i, j) ;
1516
```
1617

17-
[![License](https://img.shields.io/github/license/aureooms/js-sort.svg)](https://raw.githubusercontent.com/aureooms/js-sort/master/LICENSE)
18-
[![Version](https://img.shields.io/npm/v/@aureooms/js-sort.svg)](https://www.npmjs.org/package/@aureooms/js-sort)
19-
[![Build](https://img.shields.io/travis/aureooms/js-sort/master.svg)](https://travis-ci.org/aureooms/js-sort/branches)
20-
[![Dependencies](https://img.shields.io/david/aureooms/js-sort.svg)](https://david-dm.org/aureooms/js-sort)
21-
[![Dev dependencies](https://img.shields.io/david/dev/aureooms/js-sort.svg)](https://david-dm.org/aureooms/js-sort?type=dev)
22-
[![GitHub issues](https://img.shields.io/github/issues/aureooms/js-sort.svg)](https://github.com/aureooms/js-sort/issues)
23-
[![Downloads](https://img.shields.io/npm/dm/@aureooms/js-sort.svg)](https://www.npmjs.org/package/@aureooms/js-sort)
24-
25-
[![Code issues](https://img.shields.io/codeclimate/issues/aureooms/js-sort.svg)](https://codeclimate.com/github/aureooms/js-sort/issues)
26-
[![Code maintainability](https://img.shields.io/codeclimate/maintainability/aureooms/js-sort.svg)](https://codeclimate.com/github/aureooms/js-sort/trends/churn)
27-
[![Code coverage (cov)](https://img.shields.io/codecov/c/gh/aureooms/js-sort/master.svg)](https://codecov.io/gh/aureooms/js-sort)
28-
[![Code technical debt](https://img.shields.io/codeclimate/tech-debt/aureooms/js-sort.svg)](https://codeclimate.com/github/aureooms/js-sort/trends/technical_debt)
29-
[![Documentation](https://aureooms.github.io/js-sort//badge.svg)](https://aureooms.github.io/js-sort//source.html)
30-
[![Package size](https://img.shields.io/bundlephobia/minzip/@aureooms/js-sort)](https://bundlephobia.com/result?p=@aureooms/js-sort)
31-
32-
## Children
33-
34-
This package has several children:
35-
36-
- [aureooms/js-bucketsort](https://github.com/aureooms/js-bucketsort): bucketsort for JavaScript
37-
- [aureooms/js-countingsort](https://github.com/aureooms/js-countingsort): countingsort for JavaScript
38-
- [aureooms/js-in-situ-sort-spec](https://github.com/aureooms/js-in-situ-sort-spec): in place sorting for JavaScript
39-
- [aureooms/js-heapsort](https://github.com/aureooms/js-heapsort): heapsort for JavaScript
40-
- [aureooms/js-quicksort](https://github.com/aureooms/js-quicksort): quicksort for JavaScript
41-
- [aureooms/js-insertion-sort](https://github.com/aureooms/js-insertion-sort): Insertion sorting algorithms for JavaScript
42-
- [aureooms/js-mergesort](https://github.com/aureooms/js-mergesort): mergesort for JavaScript
43-
- [aureooms/js-odd-even-mergesort](https://github.com/aureooms/js-odd-even-mergesort): Batcher's odd-even mergesort for JavaScript
44-
- [aureooms/js-radix-sort](https://github.com/aureooms/js-radix-sort): Radix sorting algorithms for JavaScript
45-
- [aureooms/js-merging](https://github.com/aureooms/js-merging): merging for JavaScript
46-
- [aureooms/js-partition](https://github.com/aureooms/js-partition): partition for JavaScript
47-
- [aureooms/js-selection](https://github.com/aureooms/js-selection): selection for JavaScript
48-
49-
50-
## Reference
51-
52-
- http://sorting.at
18+
[![License](https://img.shields.io/github/license/aureooms/js-merge-insertion-sort.svg)](https://raw.githubusercontent.com/aureooms/js-merge-insertion-sort/master/LICENSE)
19+
[![Version](https://img.shields.io/npm/v/@aureooms/js-merge-insertion-sort.svg)](https://www.npmjs.org/package/@aureooms/js-merge-insertion-sort)
20+
[![Build](https://img.shields.io/travis/aureooms/js-merge-insertion-sort/master.svg)](https://travis-ci.org/aureooms/js-merge-insertion-sort/branches)
21+
[![Dependencies](https://img.shields.io/david/aureooms/js-merge-insertion-sort.svg)](https://david-dm.org/aureooms/js-merge-insertion-sort)
22+
[![Dev dependencies](https://img.shields.io/david/dev/aureooms/js-merge-insertion-sort.svg)](https://david-dm.org/aureooms/js-merge-insertion-sort?type=dev)
23+
[![GitHub issues](https://img.shields.io/github/issues/aureooms/js-merge-insertion-sort.svg)](https://github.com/aureooms/js-merge-insertion-sort/issues)
24+
[![Downloads](https://img.shields.io/npm/dm/@aureooms/js-merge-insertion-sort.svg)](https://www.npmjs.org/package/@aureooms/js-merge-insertion-sort)
25+
26+
[![Code issues](https://img.shields.io/codeclimate/issues/aureooms/js-merge-insertion-sort.svg)](https://codeclimate.com/github/aureooms/js-merge-insertion-sort/issues)
27+
[![Code maintainability](https://img.shields.io/codeclimate/maintainability/aureooms/js-merge-insertion-sort.svg)](https://codeclimate.com/github/aureooms/js-merge-insertion-sort/trends/churn)
28+
[![Code coverage (cov)](https://img.shields.io/codecov/c/gh/aureooms/js-merge-insertion-sort/master.svg)](https://codecov.io/gh/aureooms/js-merge-insertion-sort)
29+
[![Code technical debt](https://img.shields.io/codeclimate/tech-debt/aureooms/js-merge-insertion-sort.svg)](https://codeclimate.com/github/aureooms/js-merge-insertion-sort/trends/technical_debt)
30+
[![Documentation](https://aureooms.github.io/js-merge-insertion-sort//badge.svg)](https://aureooms.github.io/js-merge-insertion-sort//source.html)
31+
[![Package size](https://img.shields.io/bundlephobia/minzip/@aureooms/js-merge-insertion-sort)](https://bundlephobia.com/result?p=@aureooms/js-merge-insertion-sort)

doc/manual/installation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ or [npm](https://github.com/npm/npm).
55

66
### jspm
77
```terminal
8-
jspm install npm:@aureooms/js-sort
8+
jspm install npm:@aureooms/js-merge-insertion-sort
99
```
1010

1111
### npm
1212
```terminal
13-
npm install @aureooms/js-sort --save
13+
npm install @aureooms/js-merge-insertion-sort --save
1414
```

doc/manual/usage.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'regenerator-runtime/runtime' ;
99

1010
Then
1111
```js
12-
const measure = require( '@aureooms/js-sort' ) ;
12+
const measure = require( '@aureooms/js-merge-insertion-sort' ) ;
1313
// or
14-
import measure from '@aureooms/js-sort' ;
14+
import measure from '@aureooms/js-merge-insertion-sort' ;
1515
```

doc/scripts/header.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ domReady(function(){
1313

1414
var projectname = document.createElement('a');
1515
projectname.classList.add('project-name');
16-
projectname.text = 'aureooms/js-sort';
16+
projectname.text = 'aureooms/js-merge-insertion-sort';
1717
projectname.href = './index.html' ;
1818

1919
var header = document.getElementsByTagName('header')[0] ;
2020
header.insertBefore(projectname,header.firstChild);
2121

2222
var testlink = document.querySelector('header > a[data-ice="testLink"]') ;
23-
testlink.href = 'https://coveralls.io/github/aureooms/js-sort' ;
23+
testlink.href = 'https://coveralls.io/github/aureooms/js-merge-insertion-sort' ;
2424
testlink.target = '_BLANK' ;
2525

2626
var searchBox = document.querySelector('.search-box');

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@aureooms/js-sort",
2+
"name": "@aureooms/js-merge-insertion-sort",
33
"description": "sorting code bricks for JavaScript",
44
"version": "7.0.0",
55
"author": "Aurélien Ooms <[email protected]>",
@@ -73,7 +73,7 @@
7373
}
7474
},
7575
"bugs": {
76-
"url": "https://github.com/aureooms/js-sort/issues"
76+
"url": "https://github.com/aureooms/js-merge-insertion-sort/issues"
7777
},
7878
"dependencies": {},
7979
"devDependencies": {
@@ -105,7 +105,7 @@
105105
"files": [
106106
"lib"
107107
],
108-
"homepage": "http://aureooms.github.io/js-sort/",
108+
"homepage": "http://aureooms.github.io/js-merge-insertion-sort/",
109109
"keywords": [
110110
"bricks",
111111
"javascript",
@@ -117,7 +117,7 @@
117117
"license": "AGPL-3.0",
118118
"main": "lib/index.js",
119119
"repository": {
120-
"url": "https://github.com/aureooms/js-sort.git",
120+
"url": "https://github.com/aureooms/js-merge-insertion-sort.git",
121121
"type": "git"
122122
},
123123
"scripts": {

src/sort/fordjohnson.js renamed to src/fordjohnson.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

2-
export function _fordjohnson ( binarysearch ) {
2+
export default function fordjohnson ( binarysearch ) {
33

4-
const fordjohnson = function ( compare , swap , a , i , j ) {
4+
const sort = function ( compare , swap , a , i , j ) {
55

66
var m , k , t , y , p , q , r , x , l , w , s , pairswap ;
77

@@ -29,7 +29,7 @@ export function _fordjohnson ( binarysearch ) {
2929
swap( a , i + m , j + m ) ;
3030
} ;
3131

32-
fordjohnson( compare , pairswap , a , i , i + m ) ;
32+
sort( compare , pairswap , a , i , i + m ) ;
3333

3434
// merge the rest of the array into the front, one item at a time
3535

@@ -88,6 +88,6 @@ export function _fordjohnson ( binarysearch ) {
8888

8989
} ;
9090

91-
return fordjohnson ;
91+
return sort ;
9292

9393
}

src/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1-
export * from './sort' ;
2-
export * from './utils' ;
1+
import fordjohnson from './fordjohnson' ;
2+
3+
/* eslint import/no-anonymous-default-export: [2, {"allowObject": true}] */
4+
export default {
5+
fordjohnson ,
6+
} ;
7+
8+
export {
9+
fordjohnson ,
10+
} ;

src/sort/bubblesort.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/sort/index.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/sort/selectionsort.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/utils/firstInversion.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/utils/index.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/utils/isSorted.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/utils/whole.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

test/src/firstInversion.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

test/src/inplacesort.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

test/src/isSorted.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

test/src/spec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import ava from 'ava' ;
2+
3+
import * as spec from "@aureooms/js-in-situ-sort-spec" ;
4+
5+
import { swap } from "@aureooms/js-array" ;
6+
import { binarysearch } from "@aureooms/js-search" ;
7+
import {fordjohnson} from "../../src" ;
8+
9+
const fj = fordjohnson( binarysearch ) ;
10+
const sort = (compare, a, i, j) => fj(compare, swap, a, i, j) ;
11+
12+
spec.test( ava , [ [ "fordjohnson" , sort ] ] ) ;

0 commit comments

Comments
 (0)