{"id":21027054,"url":"https://github.com/tom2strobl/order-by-sort","last_synced_at":"2026-01-20T08:33:47.868Z","repository":{"id":57316081,"uuid":"347174260","full_name":"tom2strobl/order-by-sort","owner":"tom2strobl","description":"Takes an array of objects and sorts them by an arbitrary number of common `string`, `number` or `Date` fields with control over direction and placement of `null` elements. Apart from the given fields it retains original order (stable sort). The original array will not be modified.","archived":false,"fork":false,"pushed_at":"2022-10-17T12:50:02.000Z","size":333,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-20T01:09:22.044Z","etag":null,"topics":["javascript","sorting","sorting-algorithms-implemented","typescript"],"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/tom2strobl.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":"2021-03-12T19:20:48.000Z","updated_at":"2023-01-20T21:37:45.000Z","dependencies_parsed_at":"2022-09-18T20:33:45.134Z","dependency_job_id":null,"html_url":"https://github.com/tom2strobl/order-by-sort","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/tom2strobl/order-by-sort","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tom2strobl%2Forder-by-sort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tom2strobl%2Forder-by-sort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tom2strobl%2Forder-by-sort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tom2strobl%2Forder-by-sort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tom2strobl","download_url":"https://codeload.github.com/tom2strobl/order-by-sort/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tom2strobl%2Forder-by-sort/sbom","scorecard":{"id":891875,"data":{"date":"2025-08-18","repo":{"name":"github.com/tom2strobl/order-by-sort","commit":"ecad9f8827152fc059c73b964dc96a385a8fd20d"},"scorecard":{"version":"v5.2.1-41-g40576783","commit":"40576783fda6698350fcbbeaea760ff827433034"},"score":1.3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/11 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#branch-protection"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#signed-releases"}},{"name":"Vulnerabilities","score":0,"reason":"24 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-24T12:09:57.605Z","repository_id":57316081,"created_at":"2025-08-24T12:09:57.605Z","updated_at":"2025-08-24T12:09:57.605Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28599048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T02:08:49.799Z","status":"ssl_error","status_checked_at":"2026-01-20T02:08:44.148Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["javascript","sorting","sorting-algorithms-implemented","typescript"],"created_at":"2024-11-19T11:47:29.591Z","updated_at":"2026-01-20T08:33:47.853Z","avatar_url":"https://github.com/tom2strobl.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# order-by-sort\n\n\u003e Takes an array of objects and sorts them by an arbitrary number of common `string`, `number` or `Date` fields with control over direction and placement of `null` elements. Apart from the given fields it retains original order (stable sort). The original array will not be modified.\n\nParticularly useful for emulating behaviour of postgres sorting and accepts PostgreSQL compliant `ORDER BY` options (`'asc', 'asc_nulls_first', 'asc_nulls_last', 'desc', 'desc_nulls_first', 'desc_nulls_last'`). Which eg. is something you could want if you want to supply correct ordering after mutations in optimistic UI updates on the client before a server responds. Order by options are also 1:1 the one's Hasura uses in their GraphQL schemas.\n\n- *zero* dependencies\n- *fully typed* in typescript\n- *100%* code test *coverage* (100% Statements 43/43, 100% Branches 54/54, 100% Functions 8/8, 100% Lines 43/43)\n- *small* footprint (1.2kb minified)\n- leverages vanilla arr.sort to benefit from improving browser implementations\n- written in an actually readable way\n\n## Installation\n\n`npm i order-by-sort` or `yarn add order-by-sort`\n\n## Usage\n\n```typescript\nconst entityArray = [\n  { id: 5, rating: null, author: 'Wilma', date: '2021-01-02' },\n  { id: 7, rating: null, author: null, date: '2021-01-01' },\n  { id: 1, rating: 1, author: 'Paul', date: '2021-01-03' },\n  { id: 2, rating: 3, author: 'Anne', date: '2021-01-01' },\n  { id: 4, rating: 3, author: 'Paul', date: '2021-01-03' },\n  { id: 3, rating: null, author: 'Frank', date: '2021-01-01' },\n  { id: 6, rating: null, author: null, date: '2021-01-01' },\n]\nconst orderByArray = [\n  { field: 'rating', value: 'desc_nulls_first' },\n  { field: 'date', value: 'asc' }\n]\nconst sortedArray = orderBySort(entityArray, orderByArray)\n/*\nsortedArray is now [\n  { id: 7, rating: null, author: null, date: '2021-01-01' },\n  { id: 3, rating: null, author: 'Frank', date: '2021-01-01' },\n  { id: 6, rating: null, author: null, date: '2021-01-01' },\n  { id: 5, rating: null, author: 'Wilma', date: '2021-01-02' },\n  { id: 2, rating: 3, author: 'Anne', date: '2021-01-01' },\n  { id: 4, rating: 3, author: 'Paul', date: '2021-01-03' },\n  { id: 1, rating: 1, author: 'Paul', date: '2021-01-03' }\n]\n*/\n```\n\n`entityArray` OrderBySortItem[] — Array of Objects with common string, number or Date fields to sort by.\n`orderByArray` OrderByEntry[] — Array of objects with ordering definitions in pairs of field/value where value is a valid `OrderBySortOrderOperator`\n\nSee `src/index.test.js` for more examples and `src/index.ts` for types.\n\nIn terms of performance the above example runs at `308 572 ops/s, ±0.28%`, but as a disclaimer: Performance is not yet tested for ridiculously large datasets. But feel free to do so and let me know.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftom2strobl%2Forder-by-sort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftom2strobl%2Forder-by-sort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftom2strobl%2Forder-by-sort/lists"}