{"id":16399923,"url":"https://github.com/jayrbolton/node-insertion-sort","last_synced_at":"2026-02-28T02:06:51.291Z","repository":{"id":145317671,"uuid":"115747036","full_name":"jayrbolton/node-insertion-sort","owner":"jayrbolton","description":"Insertion sort implementation","archived":false,"fork":false,"pushed_at":"2017-12-29T19:00:53.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-23T11:29:15.761Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jayrbolton.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-29T19:00:35.000Z","updated_at":"2017-12-29T19:00:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"f18110bf-a0d8-40cc-b76b-15f407288ae6","html_url":"https://github.com/jayrbolton/node-insertion-sort","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jayrbolton/node-insertion-sort","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayrbolton%2Fnode-insertion-sort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayrbolton%2Fnode-insertion-sort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayrbolton%2Fnode-insertion-sort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayrbolton%2Fnode-insertion-sort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jayrbolton","download_url":"https://codeload.github.com/jayrbolton/node-insertion-sort/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayrbolton%2Fnode-insertion-sort/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29922841,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T19:37:42.220Z","status":"online","status_checked_at":"2026-02-28T02:00:07.010Z","response_time":90,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T05:26:15.944Z","updated_at":"2026-02-28T02:06:51.277Z","avatar_url":"https://github.com/jayrbolton.png","language":"JavaScript","readme":"# Node insertion sort\n\nInsertion sort is a simple sorting algorithm. In most cases, you will want to use quicksort, heapsort, or merge sort, but there are some exceptions:\n\n\u003e Although it is one of the elementary sorting algorithms with O(n^2) worst-case time, insertion sort is the algorithm of choice either when the data is nearly sorted (because it is adaptive) or when the problem size is small (because it has low overhead).\n\u003e\n\u003e For these reasons, and because it is also stable, insertion sort is often used as the recursive base case (when the problem size is small) for higher overhead divide-and-conquer sorting algorithms, such as merge sort or quick sort.\n\n## Usage\n\n```js\nvar sort = require('@jayrbolton/insertion-sort')\n\nvar sorted = sort([4, -1, 2, 3])\n\n// Pass in a custom comparison function\nsort([{x: 1}, {x: 2}], compare)\nfunction compare (obj1, obj2) {\n  if (obj1.x \u003c obj2.x) return -1\n  if (obj1.x \u003e obj2.x) reuturn 1\n  else return 0\n}\n```\n\n*Note* that this function will mutate the array you pass into it -- this algorithm is totally in-place.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjayrbolton%2Fnode-insertion-sort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjayrbolton%2Fnode-insertion-sort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjayrbolton%2Fnode-insertion-sort/lists"}