{"id":28608222,"url":"https://github.com/vfile/vfile-sort","last_synced_at":"2025-12-12T04:05:21.976Z","repository":{"id":34586938,"uuid":"38533998","full_name":"vfile/vfile-sort","owner":"vfile","description":"utility to sort messages by line/column","archived":false,"fork":false,"pushed_at":"2023-06-15T10:12:58.000Z","size":96,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-06-11T15:11:32.035Z","etag":null,"topics":["file","sort","vfile","vfile-util","virtual"],"latest_commit_sha":null,"homepage":"https://unifiedjs.com","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/vfile.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"unifiedjs","open_collective":"unified"}},"created_at":"2015-07-04T13:01:23.000Z","updated_at":"2024-05-05T10:43:43.000Z","dependencies_parsed_at":"2024-06-18T16:55:22.546Z","dependency_job_id":null,"html_url":"https://github.com/vfile/vfile-sort","commit_stats":{"total_commits":93,"total_committers":3,"mean_commits":31.0,"dds":"0.032258064516129004","last_synced_commit":"e4bd528624cdff7b6778792d7f2d744614900b7a"},"previous_names":["wooorm/vfile-sort"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/vfile/vfile-sort","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vfile%2Fvfile-sort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vfile%2Fvfile-sort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vfile%2Fvfile-sort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vfile%2Fvfile-sort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vfile","download_url":"https://codeload.github.com/vfile/vfile-sort/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vfile%2Fvfile-sort/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259346985,"owners_count":22843814,"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":["file","sort","vfile","vfile-util","virtual"],"created_at":"2025-06-11T21:40:23.118Z","updated_at":"2025-12-12T04:05:21.551Z","avatar_url":"https://github.com/vfile.png","language":"JavaScript","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified"],"categories":[],"sub_categories":[],"readme":"# vfile-sort\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n[![Sponsors][sponsors-badge]][collective]\n[![Backers][backers-badge]][collective]\n[![Chat][chat-badge]][chat]\n\n[`vfile`][vfile] utility to sort files or messages.\n\n## Contents\n\n*   [What is this?](#what-is-this)\n*   [When should I use this?](#when-should-i-use-this)\n*   [Install](#install)\n*   [Use](#use)\n*   [API](#api)\n    *   [`compareFile(a, b)`](#comparefilea-b)\n    *   [`compareMessage(a, b)`](#comparemessagea-b)\n*   [Types](#types)\n*   [Compatibility](#compatibility)\n*   [Contribute](#contribute)\n*   [License](#license)\n\n## What is this?\n\nThis package exposes comparators for vfile files and messages.\n\n## When should I use this?\n\nYou can use this right before a reporter is used to give humans a coherent\nreport.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install vfile-sort\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {sort} from 'https://esm.sh/vfile-sort@4'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import {sort} from 'https://esm.sh/vfile-sort@4?bundle'\n\u003c/script\u003e\n```\n\n## Use\n\n```js\nimport {VFile} from 'vfile'\nimport {VFileMessage} from 'vfile-message'\nimport {compareFile, compareMessage} from 'vfile-sort'\n\nconsole.log(\n  [\n    new VFileMessage('Error!', {place: {line: 3, column: 1}}),\n    new VFileMessage('Another!', {place: {line: 2, column: 2}})\n  ]\n    .toSorted(compareMessage)\n    .map(String)\n) //=\u003e ['2:2: Another!', '3:1: Error!']\n\nconsole.log(\n  [\n    new VFile(new URL(import.meta.url)),\n    new VFile(new URL('.', import.meta.url))\n  ]\n    .toSorted(compareFile)\n    .map((d) =\u003e d.path)\n) //=\u003e ['/Users/tilde/Projects/oss/vfile-sort/', '/Users/tilde/Projects/oss/vfile-sort/example.js']\n```\n\n## API\n\nThis package exports the identifiers [`compareFile`][api-compare-file] and\n[`compareMessage`][api-compare-message].\nThere is no default export.\n\n### `compareFile(a, b)`\n\nCompare files (since: `4.0.0`).\n\n###### Parameters\n\n*   `a` ([`VFile`][vfile])\n    — file\n*   `b` ([`VFile`][vfile])\n    — other file\n\n###### Returns\n\nOrder (`number`).\n\n### `compareMessage(a, b)`\n\nCompare messages (since: `4.0.0`).\n\n###### Algorithm\n\nIt first sorts by line/column: earlier messages come first.\nWhen two messages occurr at the same place, sorts fatal error before\nwarnings, before info messages.\nFinally, it sorts using `localeCompare` on `source`, `ruleId`, or finally\n`reason`.\n\n###### Parameters\n\n*   `a` ([`VFile`][vfile])\n    — message\n*   `b` ([`VFile`][vfile])\n    — other message\n\n###### Returns\n\nOrder (`number`).\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports no additional types.\n\n## Compatibility\n\nProjects maintained by the unified collective are compatible with maintained\nversions of Node.js.\n\nWhen we cut a new major release, we drop support for unmaintained versions of\nNode.\nThis means we try to keep the current release line, `vfile-sort@^4`,\ncompatible with Node.js 16.\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`vfile/.github`][health] for ways to\nget started.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n\u003c!-- Definitions --\u003e\n\n[build-badge]: https://github.com/vfile/vfile-sort/workflows/main/badge.svg\n\n[build]: https://github.com/vfile/vfile-sort/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/vfile/vfile-sort.svg\n\n[coverage]: https://codecov.io/github/vfile/vfile-sort\n\n[downloads-badge]: https://img.shields.io/npm/dm/vfile-sort.svg\n\n[downloads]: https://www.npmjs.com/package/vfile-sort\n\n[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size\u0026query=$.size.compressedSize\u0026url=https://deno.bundlejs.com/?q=vfile-sort\n\n[size]: https://bundlejs.com/?q=vfile-sort\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[collective]: https://opencollective.com/unified\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[chat]: https://github.com/vfile/vfile/discussions\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[typescript]: https://www.typescriptlang.org\n\n[contributing]: https://github.com/vfile/.github/blob/main/contributing.md\n\n[support]: https://github.com/vfile/.github/blob/main/support.md\n\n[health]: https://github.com/vfile/.github\n\n[coc]: https://github.com/vfile/.github/blob/main/code-of-conduct.md\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[vfile]: https://github.com/vfile/vfile\n\n[api-compare-file]: #comparefilea-b\n\n[api-compare-message]: #comparemessagea-b\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvfile%2Fvfile-sort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvfile%2Fvfile-sort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvfile%2Fvfile-sort/lists"}