{"id":15483367,"url":"https://github.com/hackergrrl/sort-subset","last_synced_at":"2025-04-12T06:12:49.031Z","repository":{"id":57366336,"uuid":"72959224","full_name":"hackergrrl/sort-subset","owner":"hackergrrl","description":"sort a subset of an array in-place","archived":false,"fork":false,"pushed_at":"2016-11-07T01:20:33.000Z","size":5,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T06:12:41.682Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/hackergrrl.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}},"created_at":"2016-11-05T23:30:35.000Z","updated_at":"2019-07-15T17:38:40.000Z","dependencies_parsed_at":"2022-08-23T20:10:37.765Z","dependency_job_id":null,"html_url":"https://github.com/hackergrrl/sort-subset","commit_stats":null,"previous_names":["noffle/sort-subset"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackergrrl%2Fsort-subset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackergrrl%2Fsort-subset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackergrrl%2Fsort-subset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackergrrl%2Fsort-subset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hackergrrl","download_url":"https://codeload.github.com/hackergrrl/sort-subset/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248525138,"owners_count":21118619,"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":[],"created_at":"2024-10-02T05:14:24.343Z","updated_at":"2025-04-12T06:12:49.011Z","avatar_url":"https://github.com/hackergrrl.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sort-subset\n\n\u003e Sort a subset of an array in-place.\n\n## Usage\n\nLet's sort an array with heterogenous types in-place, without disturbing other\ntypes' sort order.\n\n```js\nvar subsort = require('sort-subset')\n\nvar data = [\n  { type: 'apple', id: 7 },\n  { type: 'apple', id: 12 },\n  { type: 'orange', id: 17 },\n  { type: 'apple', id: 2 },\n  { type: 'orange', id: 9 }\n]\n\nvar filter = function (elm) { return elm.type === 'apple' }\nvar sort = function (a, b) { return a.id - b.id }\nsubsort(data, filter, sort)\n\nconsole.log(data)\n```\n\nwill output\n\n```\n[\n  { type: 'apple', id: 2 },\n  { type: 'apple', id: 7 },\n  { type: 'orange', id: 17 },\n  { type: 'apple', id: 12 },\n  { type: 'orange', id: 9 }\n]\n```\n\n## API\n\n```js\nvar subsort = require('sort-subset')\n```\n\n### subsort(array, filterFn, compareFn)\n\nSorts the array `array` in-place. The function `filterFn` is used to compute the\narray subset to sort (signature `function (element, idex)`), and `compareFn` is\nthe function used to compare elements to perform the sort (signature `function\n(a, b)`).\n\n\n## Install\n\nWith [npm](https://npmjs.org/) installed, run\n\n```\n$ npm install sort-subset\n```\n\n## License\n\nISC\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackergrrl%2Fsort-subset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhackergrrl%2Fsort-subset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackergrrl%2Fsort-subset/lists"}