{
	"name": "timsort",
	"versions": {
		"0.1.0": {
			"name": "timsort",
			"version": "0.1.0",
			"author": {
				"name": "Marco Ziccardi",
				"url": "http://mziccard.me/"
			},
			"description": "TimSort: Fast Sorting for Node.js",
			"homepage": "https://github.com/mziccard/node-timsort",
			"main": "index.js",
			"directories": {
				"test": "./test",
				"benchmark": "./benchmark"
			},
			"dependencies": {
				"is": "~3.0.1"
			},
			"devDependencies": {
				"mocha": "~2.2.5",
				"assert": "~1.3.0",
				"jshint": "~2.8.0"
			},
			"scripts": {
				"test": "mocha --timeout 5000",
				"lint": "jshint index.js test/*.js benchmark/index.js",
				"benchmark": "node benchmark/index.js"
			},
			"repository": {
				"type": "git",
				"url": "git+https://github.com/mziccard/node-timsort.git"
			},
			"keywords": [
				"sort",
				"compare",
				"TimSort",
				"algorithm",
				"python",
				"performance"
			],
			"license": "MIT",
			"bugs": {
				"url": "https://github.com/mziccard/node-timsort/issues"
			},
			"gitHead": "349adf5afcee21d9ec34e003642ba4bd4d3604a5",
			"_id": "timsort@0.1.0",
			"_shasum": "7bb47dc42b713d138118b10a0302ac6198902050",
			"_from": ".",
			"_npmVersion": "2.11.3",
			"_nodeVersion": "0.12.7",
			"_npmUser": {
				"name": "mziccard",
				"email": "marco.ziccard@gmail.com"
			},
			"dist": {
				"shasum": "7bb47dc42b713d138118b10a0302ac6198902050",
				"tarball": "https://registry.npmjs.org/timsort/-/timsort-0.1.0.tgz"
			},
			"maintainers": [
				{
					"name": "mziccard",
					"email": "marco.ziccard@gmail.com"
				}
			],
			"contributors": []
		},
		"0.1.1": {
			"name": "timsort",
			"version": "0.1.1",
			"author": {
				"name": "Marco Ziccardi",
				"url": "http://mziccard.me/"
			},
			"description": "TimSort: Fast Sorting for Node.js",
			"homepage": "https://github.com/mziccard/node-timsort",
			"main": "index.js",
			"directories": {
				"test": "./test",
				"benchmark": "./benchmark"
			},
			"dependencies": {
				"is": "~3.0.1"
			},
			"devDependencies": {
				"mocha": "~2.2.5",
				"assert": "~1.3.0",
				"jshint": "~2.8.0"
			},
			"scripts": {
				"test": "mocha --timeout 5000",
				"lint": "jshint index.js test/*.js benchmark/index.js",
				"benchmark": "node benchmark/index.js"
			},
			"repository": {
				"type": "git",
				"url": "git+https://github.com/mziccard/node-timsort.git"
			},
			"keywords": [
				"sort",
				"compare",
				"TimSort",
				"algorithm",
				"python",
				"performance"
			],
			"license": "MIT",
			"bugs": {
				"url": "https://github.com/mziccard/node-timsort/issues"
			},
			"gitHead": "e31a782b11da830cff289e29fb992fcc3b88066a",
			"_id": "timsort@0.1.1",
			"_shasum": "eb3447dbac976bf883a882bc338da569971239e9",
			"_from": ".",
			"_npmVersion": "2.11.3",
			"_nodeVersion": "0.12.7",
			"_npmUser": {
				"name": "mziccard",
				"email": "marco.ziccard@gmail.com"
			},
			"dist": {
				"shasum": "eb3447dbac976bf883a882bc338da569971239e9",
				"tarball": "https://registry.npmjs.org/timsort/-/timsort-0.1.1.tgz"
			},
			"maintainers": [
				{
					"name": "mziccard",
					"email": "marco.ziccard@gmail.com"
				}
			],
			"contributors": []
		},
		"0.2.0": {
			"name": "timsort",
			"version": "0.2.0",
			"author": {
				"name": "Marco Ziccardi",
				"url": "http://mziccard.me/"
			},
			"description": "TimSort: Fast Sorting for Node.js",
			"homepage": "https://github.com/mziccard/node-timsort",
			"main": "index.js",
			"directories": {
				"test": "./test",
				"benchmark": "./benchmark"
			},
			"dependencies": {},
			"devDependencies": {
				"assert": "~1.3.0",
				"babel-eslint": "^4.0.5",
				"eslint": "^1.1.0",
				"grunt": "^0.4.5",
				"grunt-babel": "^5.0.1",
				"grunt-banner": "^0.5.0",
				"grunt-contrib-clean": "^0.6.0",
				"grunt-contrib-uglify": "^0.9.1",
				"mocha": "~2.2.5"
			},
			"scripts": {
				"test": "mocha --timeout 5000",
				"lint": "eslint Gruntfile.js src/ test/ benchmark/index.js",
				"benchmark": "node benchmark/index.js"
			},
			"repository": {
				"type": "git",
				"url": "git+https://github.com/mziccard/node-timsort.git"
			},
			"keywords": [
				"sort",
				"compare",
				"TimSort",
				"algorithm",
				"python",
				"performance"
			],
			"license": "MIT",
			"bugs": {
				"url": "https://github.com/mziccard/node-timsort/issues"
			},
			"gitHead": "62da629189b1cafaeda1b731e83cfa05478f9b5f",
			"_id": "timsort@0.2.0",
			"_shasum": "298277d6a6bee7b1266ff96bc055f113bcd04c2b",
			"_from": ".",
			"_npmVersion": "2.11.3",
			"_nodeVersion": "0.12.7",
			"_npmUser": {
				"name": "mziccard",
				"email": "marco.ziccard@gmail.com"
			},
			"dist": {
				"shasum": "298277d6a6bee7b1266ff96bc055f113bcd04c2b",
				"tarball": "https://registry.npmjs.org/timsort/-/timsort-0.2.0.tgz"
			},
			"maintainers": [
				{
					"name": "mziccard",
					"email": "marco.ziccard@gmail.com"
				}
			],
			"contributors": []
		},
		"0.2.1": {
			"name": "timsort",
			"version": "0.2.1",
			"author": {
				"name": "Marco Ziccardi",
				"url": "http://mziccard.me/"
			},
			"description": "TimSort: Fast Sorting for Node.js",
			"homepage": "https://github.com/mziccard/node-timsort",
			"main": "index.js",
			"directories": {
				"test": "./test",
				"benchmark": "./benchmark"
			},
			"dependencies": {},
			"devDependencies": {
				"assert": "~1.3.0",
				"babel-eslint": "^4.0.5",
				"eslint": "^1.1.0",
				"grunt": "^0.4.5",
				"grunt-babel": "^5.0.1",
				"grunt-banner": "^0.5.0",
				"grunt-contrib-clean": "^0.6.0",
				"grunt-contrib-uglify": "^0.9.1",
				"mocha": "~2.2.5"
			},
			"scripts": {
				"test": "mocha --timeout 5000",
				"lint": "eslint Gruntfile.js src/ test/ benchmark/index.js",
				"benchmark": "node benchmark/index.js"
			},
			"repository": {
				"type": "git",
				"url": "git+https://github.com/mziccard/node-timsort.git"
			},
			"keywords": [
				"sort",
				"compare",
				"TimSort",
				"algorithm",
				"python",
				"performance"
			],
			"license": "MIT",
			"bugs": {
				"url": "https://github.com/mziccard/node-timsort/issues"
			},
			"gitHead": "8012d0f71c683cda7c6b7edb3047fae1db51ca5a",
			"_id": "timsort@0.2.1",
			"_shasum": "53d98d79f5f45b1fac0e4ee8134b3c799faec0d6",
			"_from": ".",
			"_npmVersion": "2.11.3",
			"_nodeVersion": "0.12.7",
			"_npmUser": {
				"name": "mziccard",
				"email": "marco.ziccard@gmail.com"
			},
			"dist": {
				"shasum": "53d98d79f5f45b1fac0e4ee8134b3c799faec0d6",
				"tarball": "https://registry.npmjs.org/timsort/-/timsort-0.2.1.tgz"
			},
			"maintainers": [
				{
					"name": "mziccard",
					"email": "marco.ziccard@gmail.com"
				}
			],
			"contributors": []
		},
		"0.3.0": {
			"name": "timsort",
			"version": "0.3.0",
			"author": {
				"name": "Marco Ziccardi",
				"url": "http://mziccard.me/"
			},
			"description": "TimSort: Fast Sorting for Node.js",
			"homepage": "https://github.com/mziccard/node-timsort",
			"main": "index.js",
			"directories": {
				"test": "./test",
				"benchmark": "./benchmark"
			},
			"dependencies": {},
			"devDependencies": {
				"assert": "~1.3.0",
				"babel-eslint": "^4.0.5",
				"eslint": "^1.1.0",
				"grunt": "^0.4.5",
				"grunt-babel": "^5.0.1",
				"grunt-banner": "^0.5.0",
				"grunt-contrib-clean": "^0.6.0",
				"grunt-contrib-uglify": "^0.9.1",
				"mocha": "~2.2.5"
			},
			"scripts": {
				"test": "mocha --timeout 5000",
				"lint": "eslint Gruntfile.js src/ test/ benchmark/index.js",
				"benchmark": "node benchmark/index.js"
			},
			"repository": {
				"type": "git",
				"url": "git+https://github.com/mziccard/node-timsort.git"
			},
			"keywords": [
				"sort",
				"compare",
				"TimSort",
				"algorithm",
				"python",
				"performance"
			],
			"license": "MIT",
			"bugs": {
				"url": "https://github.com/mziccard/node-timsort/issues"
			},
			"gitHead": "f8acc9e336117356d354ccb15133d10c92444322",
			"_id": "timsort@0.3.0",
			"_shasum": "405411a8e7e6339fe64db9a234de11dc31e02bd4",
			"_from": ".",
			"_npmVersion": "3.10.3",
			"_nodeVersion": "6.3.1",
			"_npmUser": {
				"name": "mziccard",
				"email": "marco.ziccard@gmail.com"
			},
			"dist": {
				"shasum": "405411a8e7e6339fe64db9a234de11dc31e02bd4",
				"tarball": "https://registry.npmjs.org/timsort/-/timsort-0.3.0.tgz"
			},
			"maintainers": [
				{
					"name": "mziccard",
					"email": "marco.ziccard@gmail.com"
				}
			],
			"_npmOperationalInternal": {
				"host": "packages-16-east.internal.npmjs.com",
				"tmp": "tmp/timsort-0.3.0.tgz_1469389289282_0.051012826384976506"
			},
			"contributors": []
		}
	},
	"time": {
		"modified": "2016-07-24T19:41:31.319Z",
		"created": "2015-08-10T10:25:05.149Z",
		"0.1.0": "2015-08-10T10:25:05.149Z",
		"0.1.1": "2015-08-11T21:10:29.512Z",
		"0.2.0": "2015-08-17T15:28:46.314Z",
		"0.2.1": "2015-08-17T17:00:49.563Z",
		"0.3.0": "2016-07-24T19:41:31.319Z"
	},
	"users": {},
	"dist-tags": {
		"latest": "0.3.0"
	},
	"_uplinks": {
		"npmjs": {
			"etag": "W/\"c56dcbc7417456e3879e39e39a8d5e2c\"",
			"fetched": 1600679306791
		}
	},
	"_distfiles": {
		"timsort-0.1.0.tgz": {
			"url": "https://registry.npmjs.org/timsort/-/timsort-0.1.0.tgz",
			"sha": "7bb47dc42b713d138118b10a0302ac6198902050",
			"registry": "npmjs"
		},
		"timsort-0.1.1.tgz": {
			"url": "https://registry.npmjs.org/timsort/-/timsort-0.1.1.tgz",
			"sha": "eb3447dbac976bf883a882bc338da569971239e9",
			"registry": "npmjs"
		},
		"timsort-0.2.0.tgz": {
			"url": "https://registry.npmjs.org/timsort/-/timsort-0.2.0.tgz",
			"sha": "298277d6a6bee7b1266ff96bc055f113bcd04c2b",
			"registry": "npmjs"
		},
		"timsort-0.2.1.tgz": {
			"url": "https://registry.npmjs.org/timsort/-/timsort-0.2.1.tgz",
			"sha": "53d98d79f5f45b1fac0e4ee8134b3c799faec0d6",
			"registry": "npmjs"
		},
		"timsort-0.3.0.tgz": {
			"url": "https://registry.npmjs.org/timsort/-/timsort-0.3.0.tgz",
			"sha": "405411a8e7e6339fe64db9a234de11dc31e02bd4",
			"registry": "npmjs"
		}
	},
	"_attachments": {
		"timsort-0.3.0.tgz": {
			"shasum": "405411a8e7e6339fe64db9a234de11dc31e02bd4"
		}
	},
	"_rev": "2-e3d92b9a1b86d804",
	"_id": "timsort",
	"readme": "# Node-TimSort: Fast Sorting for Node.js\n\n[![Build Status](https://travis-ci.org/mziccard/node-timsort.svg?branch=master)](https://travis-ci.org/mziccard/node-timsort)\n[![npm version](https://badge.fury.io/js/timsort.svg)](https://www.npmjs.com/package/timsort)\n\nAn adaptive and **stable** sort algorithm based on merging that requires fewer than nlog(n) \ncomparisons when run on partially sorted arrays. The algorithm uses O(n) memory and still runs in O(nlogn) \n(worst case) on random arrays.  \nThis implementation is based on the original \n[TimSort](http://svn.python.org/projects/python/trunk/Objects/listsort.txt) developed \nby Tim Peters for Python's lists (code [here](http://svn.python.org/projects/python/trunk/Objects/listobject.c)).\nTimSort has been also adopted in Java starting from version 7.\n\n## Acknowledgments\n\n- @novacrazy: ported the module to ES6/ES7 and made it available via bower\n- @kasperisager: implemented faster lexicographic comparison of small integers\n\n## Usage\n\nInstall the package with npm:\n```\nnpm install --save timsort\n```\nAnd use it:\n```javascript\nvar TimSort = require('timsort');\n\nvar arr = [...];\nTimSort.sort(arr);\n```\nYou can also install it with bower:\n```\nbower install timsort\n```\nAs `array.sort()` by default the `timsort` module sorts according to \nlexicographical order. \nYou can also provide your own compare function (to sort any object) as:\n```javascript\nfunction numberCompare(a,b) {\n    return a-b;\n}\n\nvar arr = [...];\nvar TimSort = require('timsort');\nTimSort.sort(arr, numberCompare);\n```\nYou can also sort only a specific subrange of the array:\n```javascript\nTimSort.sort(arr, 5, 10);\nTimSort.sort(arr, numberCompare, 5, 10);\n```\n\n## Performance\n\nA benchmark is provided in `benchmark/index.js`. It compares the `timsort` module against \nthe default `array.sort` method in the numerical sorting of different types of integer array \n(as described [here](http://svn.python.org/projects/python/trunk/Objects/listsort.txt)):\n\n-  *Random array*\n-  *Descending array*\n-  *Ascending array*\n-  *Ascending array with 3 random exchanges*\n-  *Ascending array with 10 random numbers in the end*\n-  *Array of equal elements*\n-  *Random Array with many duplicates*\n-  *Random Array with some duplicates*\n\nFor any of the array types the sorting is repeated several times and for \ndifferent array sizes, average execution time is then printed. \nI run the benchmark on Node v6.3.1 (both pre-compiled and compiled from source,\nresults are very similar), obtaining the following values:\n\n<table>\n  <tr>\n    <th></th><th></th>\n    <th colspan=\"2\">Execution Time (ns)</th>\n    <th rowspan=\"2\">Speedup</th>\n  </tr>\n  <tr>\n    <th>Array Type</th>\n    <th>Length</th>\n    <th>TimSort.sort</th>\n    <th>array.sort</th>\n  </tr>\n<tbody>\n <tr>\n  <td rowspan=\"4\">Random</td><td>10</td><td>404</td><td>1583</td><td>3.91</td>\n </tr>\n <tr>\n  <td>100</td><td>7147</td><td>4442</td><td>0.62</td>\n </tr>\n <tr>\n  <td>1000</td><td>96395</td><td>59979</td><td>0.62</td>\n </tr>\n <tr>\n  <td>10000</td><td>1341044</td><td>6098065</td><td>4.55</td>\n </tr>\n <tr>\n  <td rowspan=\"4\">Descending</td><td>10</td><td>180</td><td>1881</td><td>10.41</td>\n </tr>\n <tr>\n  <td>100</td><td>682</td><td>19210</td><td>28.14</td>\n</tr>\n <tr>\n  <td>1000</td><td>3809</td><td>185185</td><td>48.61</td>\n </tr>\n <tr>\n  <td>10000</td><td>35878</td><td>5392428</td><td>150.30</td>\n </tr>\n <tr>\n  <td rowspan=\"4\">Ascending</td><td>10</td><td>173</td><td>816</td><td>4.69</td>\n </tr>\n <tr>\n  <td>100</td><td>578</td><td>18147</td><td>31.34</td>\n </tr>\n <tr>\n  <td>1000</td><td>2551</td><td>331993</td><td>130.12</td>\n </tr>\n <tr>\n  <td>10000</td><td>22098</td><td>5382446</td><td>243.57</td>\n </tr>\n <tr>\n  <td rowspan=\"4\">Ascending + 3 Rand Exc</td><td>10</td><td>232</td><td>927</td><td>3.99</td>\n </tr>\n <tr>\n  <td>100</td><td>1059</td><td>15792</td><td>14.90</td>\n </tr>\n <tr>\n  <td>1000</td><td>3525</td><td>300708</td><td>85.29</td>\n </tr>\n <tr>\n  <td>10000</td><td>27455</td><td>4781370</td><td>174.15</td>\n </tr>\n <tr>\n  <td rowspan=\"4\">Ascending + 10 Rand End</td><td>10</td><td>378</td><td>1425</td><td>3.77</td>\n </tr>\n <tr>\n  <td>100</td><td>1707</td><td>23346</td><td>13.67</td>\n </tr>\n <tr>\n  <td>1000</td><td>5818</td><td>334744</td><td>57.53</td>\n </tr>\n <tr>\n  <td>10000</td><td>38034</td><td>4985473</td><td>131.08</td>\n </tr>\n <tr>\n  <td rowspan=\"4\">Equal Elements</td><td>10</td><td>164</td><td>766</td><td>4.68</td>\n </tr>\n <tr>\n  <td>100</td><td>520</td><td>3188</td><td>6.12</td>\n </tr>\n <tr>\n  <td>1000</td><td>2340</td><td>27971</td><td>11.95</td>\n </tr>\n <tr>\n  <td>10000</td><td>17011</td><td>281672</td><td>16.56</td>\n </tr>\n <tr>\n  <td rowspan=\"4\">Many Repetitions</td><td>10</td><td>396</td><td>1482</td><td>3.74</td>\n </tr>\n <tr>\n  <td>100</td><td>7282</td><td>25267</td><td>3.47</td>\n </tr>\n <tr>\n  <td>1000</td><td>105528</td><td>420120</td><td>3.98</td>\n </tr>\n <tr>\n  <td>10000</td><td>1396120</td><td>5787399</td><td>4.15</td>\n </tr>\n <tr>\n  <td rowspan=\"4\">Some Repetitions</td><td>10</td><td>390</td><td>1463</td><td>3.75</td>\n </tr>\n <tr>\n  <td>100</td><td>6678</td><td>20082</td><td>3.01</td>\n </tr>\n <tr>\n  <td>1000</td><td>104344</td><td>374103</td><td>3.59</td>\n </tr>\n <tr>\n  <td>10000</td><td>1333816</td><td>5474000</td><td>4.10</td>\n </tr>\n</tbody>\n</table>\n\n`TimSort.sort` **is faster** than `array.sort` on almost of the tested array types.\nIn general, the more ordered the array is the better `TimSort.sort` performs with respect to `array.sort` (up to 243 times faster on already sorted arrays).\nAnd also, in general, the bigger the array the more we benefit from using\nthe `timsort` module.  \n\nThese data strongly depend on Node.js version and the machine on which the benchmark is run. I strongly encourage you to run the benchmark on your own setup with:\n```\nnpm run benchmark\n```\nPlease also notice that:\n\n-  This benchmark is far from exhaustive. Several cases are not considered \nand the results must be taken as partial\n-  *inlining* is surely playing an active role in `timsort` module's good performance\n-  A more accurate comparison of the algorithms would require implementing `array.sort` in pure javascript\nand counting element comparisons\n\n## Stability\n\nTimSort is *stable* which means that equal items maintain their relative order \nafter sorting. Stability is a desirable property for a sorting algorithm. \nConsider the following array of items with an height and a weight.\n```javascript\n[ \n  { height: 100, weight: 80 },\n  { height: 90, weight: 90 },\n  { height: 70, weight: 95 },\n  { height: 100, weight: 100 },\n  { height: 80, weight: 110 },\n  { height: 110, weight: 115 },\n  { height: 100, weight: 120 },\n  { height: 70, weight: 125 },\n  { height: 70, weight: 130 },\n  { height: 100, weight: 135 },\n  { height: 75, weight: 140 },\n  { height: 70, weight: 140 } \n]\n```\nItems are already sorted by `weight`. Sorting the array \naccording to the item's `height` with the `timsort` module \nresults in the following array:\n```javascript\n[ \n  { height: 70, weight: 95 },\n  { height: 70, weight: 125 },\n  { height: 70, weight: 130 },\n  { height: 70, weight: 140 },\n  { height: 75, weight: 140 },\n  { height: 80, weight: 110 },\n  { height: 90, weight: 90 },\n  { height: 100, weight: 80 },\n  { height: 100, weight: 100 },\n  { height: 100, weight: 120 },\n  { height: 100, weight: 135 },\n  { height: 110, weight: 115 } \n]\n```\nItems with the same  `height` are still sorted by `weight` which means they preserved their relative order.\n\n`array.sort`, instead, is not guarranteed to be *stable*. In Node v0.12.7 \nsorting the previous array by `height` with `array.sort` results in:\n```javascript\n[ \n  { height: 70, weight: 140 },\n  { height: 70, weight: 95 },\n  { height: 70, weight: 125 },\n  { height: 70, weight: 130 },\n  { height: 75, weight: 140 },\n  { height: 80, weight: 110 },\n  { height: 90, weight: 90 },\n  { height: 100, weight: 100 },\n  { height: 100, weight: 80 },\n  { height: 100, weight: 135 },\n  { height: 100, weight: 120 },\n  { height: 110, weight: 115 } \n]\n```\nAs you can see the sorting did not preserve `weight` ordering for items with the \nsame `height`."
}