{"id":15691646,"url":"https://github.com/jongha/sort-js","last_synced_at":"2025-07-16T21:36:11.384Z","repository":{"id":12383545,"uuid":"15035562","full_name":"jongha/sort-js","owner":"jongha","description":"This is sorting library for Javascript. The sorting algorithm is an algorithm that puts elements of a list in a numerical order. This library contains many sorting algorithms Bubble sort, Quicksort, Merge sort, Heapsort, Insertion sort and selection sort. These functions help what your application finds an optimal algorithm at specific data.","archived":false,"fork":false,"pushed_at":"2014-05-04T12:55:29.000Z","size":301,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-15T00:49:48.463Z","etag":null,"topics":["bubble-sort","insertion-sort","javascript","selection-sort","sorting-algorithms"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"mongodb/mongo-php-driver-legacy","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jongha.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":"2013-12-09T01:51:22.000Z","updated_at":"2024-08-25T10:09:37.000Z","dependencies_parsed_at":"2022-09-17T07:50:33.384Z","dependency_job_id":null,"html_url":"https://github.com/jongha/sort-js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jongha/sort-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongha%2Fsort-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongha%2Fsort-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongha%2Fsort-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongha%2Fsort-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jongha","download_url":"https://codeload.github.com/jongha/sort-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongha%2Fsort-js/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265542331,"owners_count":23785208,"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":["bubble-sort","insertion-sort","javascript","selection-sort","sorting-algorithms"],"created_at":"2024-10-03T18:22:39.229Z","updated_at":"2025-07-16T21:36:11.368Z","avatar_url":"https://github.com/jongha.png","language":"JavaScript","readme":"# sort-js\n[![Build Status](https://travis-ci.org/jongha/sort-js.png?branch=master)](https://travis-ci.org/jongha/sort-js)\n[![Coverage Status](https://coveralls.io/repos/jongha/sort-js/badge.png)](https://coveralls.io/r/jongha/sort-js)\n[![Dependency Status](https://gemnasium.com/jongha/sort-js.png)](https://gemnasium.com/jongha/sort-js)\n\nThis is sorting library for Javascript. The sorting algorithm is an algorithm that puts elements of a list in a numerical order. This library contains many sorting algorithms Bubble sort, Quicksort, Merge sort, Heapsort, Insertion sort and selection sort. \n\nBubble sort is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. Quicksort makes O(n log n) comparisons to sort n items. In the worst case, it makes O(n^2) comparisons, though this behavior is rare. Merge sort is a divide and conquer algorithm. Heapsort is a comparison-based sorting algorithm. Insertion sort is a simple sorting algorithm that builds the final sorted array or list one item at a time. Selection sort is specifically an in-place comparison sort.\n\nThese functions help what your application finds an optimal algorithm at specific data. \n\n\n## Test case\n\n* Case 1: Totally descending 2,000 data set to ascend.\n* Case 2: Totally ascending 2,000 data set to descend.\n* Case 3: Random 2,000 data set to ascend.\n* Case 4: Random 2,000 data set to descend.\n\n## Usage\n\nThis script is prototype of Javascript Array. First, includes the script block like below where you want.\n\n```\n\u003cscript src=\"./dist/sort.min.js\"\u003e\u003c/script\u003e\n```\n\nAnd use it. It is simple.\n\n```\nvar data = [1,2,3,4,5];\n```\n\n### Bubble Sort\n\nThe code is very simple But, slow.\n\nSpeed: 640 ms (Speed of test cases)\n\nTime complexity: O(n^2)\n\n```\ndata.bubble({ order: 'desc' }); // data == [5,4,3,2,1]\ndata.bubble({ order: 'asc' }); // data == [1,2,3,4,5]\n```\n\n### Quicksort\n\nSpeed: 21 ms (Speed of test cases)\n\nTime complexity: O(nlogn)\n\nFaster then Bubble sort.\n\n```\ndata.quick({ order: 'desc' }); // data == [5,4,3,2,1]\ndata.quick({ order: 'asc' }); // data == [1,2,3,4,5]\n```\n\n### Merge Sort\n\nSpeed: 15 ms (Speed of test cases)\n\nTime complexity: O(nlogn)\n\nFaster then Quicksort. Almost same speed with Quicksort.\n\n```\ndata.merge({ order: 'desc' }); // data == [5,4,3,2,1]\ndata.merge({ order: 'asc' }); // data == [1,2,3,4,5]\n```\n\n### Heapsort\n\nSpeed: 18 ms (Speed of test cases)\n\nTime complexity: O(nlogn)\n\nFaster then Quicksort. (The code is not optimize yet.)\n\n```\ndata.heap({ order: 'desc' }); // data == [5,4,3,2,1]\ndata.heap({ order: 'asc' }); // data == [1,2,3,4,5]\n```\n\n### Insertion Sort\n\nSpeed: 38 ms (Speed of test cases)\n\nTime complexity: O(n^2)\n\nFaster then Bubble sort. (But, the time complexity is same with bubble sort.)\n\n```\ndata.insertion({ order: 'desc' }); // data == [5,4,3,2,1]\ndata.insertion({ order: 'asc' }); // data == [1,2,3,4,5]\n```\n\n### Selection Sort\n\nSpeed: 48 ms (Speed of test cases)\n\nTime complexity: O(n^2)\n\n```\ndata.selection({ order: 'desc' }); // data == [5,4,3,2,1]\ndata.selection({ order: 'asc' }); // data == [1,2,3,4,5]\n```\n\n## License\n\nsort-js is available under the terms of the MIT License.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjongha%2Fsort-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjongha%2Fsort-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjongha%2Fsort-js/lists"}