{"id":18096246,"url":"https://github.com/bredele/algo-sort-bubble","last_synced_at":"2025-04-06T03:25:20.452Z","repository":{"id":57175959,"uuid":"87665311","full_name":"bredele/algo-sort-bubble","owner":"bredele","description":":bar_chart: Bubble sort algorithm","archived":false,"fork":false,"pushed_at":"2017-04-09T01:48:18.000Z","size":12,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-14T04:21:58.152Z","etag":null,"topics":["algorithm","bubble","math","sort","sorting-algorithms"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bredele.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-08T21:28:20.000Z","updated_at":"2020-05-27T17:29:47.000Z","dependencies_parsed_at":"2022-09-03T23:31:51.760Z","dependency_job_id":null,"html_url":"https://github.com/bredele/algo-sort-bubble","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bredele%2Falgo-sort-bubble","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bredele%2Falgo-sort-bubble/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bredele%2Falgo-sort-bubble/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bredele%2Falgo-sort-bubble/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bredele","download_url":"https://codeload.github.com/bredele/algo-sort-bubble/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247428686,"owners_count":20937524,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["algorithm","bubble","math","sort","sorting-algorithms"],"created_at":"2024-10-31T19:13:10.044Z","updated_at":"2025-04-06T03:25:20.436Z","avatar_url":"https://github.com/bredele.png","language":"JavaScript","readme":"# Bubble sort\n[![Build Status](https://travis-ci.org/bredele/algo-sort-bubble.svg?branch=master)](https://travis-ci.org/bredele/algo-sort-bubble)\n[![NPM](https://img.shields.io/npm/v/algo-sort-bubble.svg?style=flat-square)](https://www.npmjs.com/package/algo-sort-bubble)\n[![Downloads](https://img.shields.io/npm/dm/algo-sort-bubble.svg?style=flat-square)](http://npm-stat.com/charts.html?package=algo-sort-bubble)\n[![pledge](https://bredele.github.io/contributing-guide/community-pledge.svg)](https://github.com/bredele/contributing-guide/blob/master/community.md)\n\n\nBubble sort is a simple sorting algorithm that repeatedly steps through the list to be sorted, compares each pair of adjacent items and swaps them if they are in the wrong order. This algorithm is named for the way smaller or larger elements \"bubble\" to the top of the list.\n\n![](https://upload.wikimedia.org/wikipedia/commons/5/54/Sorting_bubblesort_anim.gif?uselang=fr)\n\nAlthough the algorithm is simple, it is too slow and impractical for most problems except when the inputs are in order but may occasionally have some out-of-order elements nearly in position.\n\n## Usage\n\n```js\nconst sort = require('algo-sort-bubble')\nsort([\n  0, 67, 7, 34, 54, 3, 2, 54, 1\n])\n// =\u003e [0, 1, 2, 3, 7, 34, 54, 54, 67]\n\nsort([\n  'world',\n  'foo',\n  'olivier',\n  'a'\n], (prev, next) =\u003e prev.length \u003c next.length)\n// =\u003e ['a', 'foo', 'world', 'olivier']\n```\n\n## Rabbits and Turtles\n\nAn element that is moving toward the end moves quickly (rabbit) because it takes part in successive swaps. For example, the largest element will be part of all consecutive swap in one pass until it is at the end of the list. On the other hand, an element that must move toward the beginning of the list (turtle) cannot move faster than one step per pass. For example, the smallest element will take n-1 passes (one swap per pass) where n is the element's position.\n\n## Installation\n\n```shell\nnpm install algo-sort-bubble --save\n```\n\n[![NPM](https://nodei.co/npm/algo-sort-bubble.png)](https://nodei.co/npm/algo-sort-bubble/)\n\n## Licence\n\nThe MIT License (MIT)\n\nCopyright (c) 2016 Olivier Wietrich\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbredele%2Falgo-sort-bubble","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbredele%2Falgo-sort-bubble","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbredele%2Falgo-sort-bubble/lists"}