{"id":17602371,"url":"https://github.com/simonh1701/textline-sorter","last_synced_at":"2026-02-24T00:34:20.486Z","repository":{"id":258726582,"uuid":"874925828","full_name":"simonh1701/textline-sorter","owner":"simonh1701","description":"A flexible utility for sorting lines of text.","archived":false,"fork":false,"pushed_at":"2024-10-21T07:45:33.000Z","size":113,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-17T09:55:27.482Z","etag":null,"topics":["cjs","commonjs","ecmascript","esm","javascript","nodejs","npm","sort","sorter","sorting","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/textline-sorter","language":"TypeScript","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/simonh1701.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}},"created_at":"2024-10-18T18:05:52.000Z","updated_at":"2024-10-21T07:43:01.000Z","dependencies_parsed_at":"2025-03-09T00:31:50.019Z","dependency_job_id":"dddc59e4-6cc2-4a4b-9379-769e8ff9d432","html_url":"https://github.com/simonh1701/textline-sorter","commit_stats":null,"previous_names":["simonh1701/textline-sorter"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/simonh1701/textline-sorter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonh1701%2Ftextline-sorter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonh1701%2Ftextline-sorter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonh1701%2Ftextline-sorter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonh1701%2Ftextline-sorter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonh1701","download_url":"https://codeload.github.com/simonh1701/textline-sorter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonh1701%2Ftextline-sorter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281216695,"owners_count":26463033,"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","status":"online","status_checked_at":"2025-10-27T02:00:05.855Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["cjs","commonjs","ecmascript","esm","javascript","nodejs","npm","sort","sorter","sorting","typescript"],"created_at":"2024-10-22T13:08:01.538Z","updated_at":"2025-10-29T14:42:28.999Z","avatar_url":"https://github.com/simonh1701.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# textline-sorter\n\nA flexible utility for sorting lines of text.\n\n## Features\n\n- Sort lines alphabetically, alphanumerically, or by length\n- Ascending or descending sort order\n- Option to trim whitespace\n- Option to remove empty lines\n- Option to remove duplicate lines\n\n## Installation\n\n```bash\nnpm install textline-sorter\n```\n\n## API\n\n### `sortLines(text: string, options: SortOptions): string`\n\nSorts the lines of the input text based on the provided options.\n\n#### Parameters\n\n- `text`: The input text to sort.\n- `options`: An object of type `SortOptions` specifying the sorting behavior.\n\n#### SortOptions\n\n- `order`: `\"alphabetical\" | \"alphanumerical\" | \"length\"` - The sorting method to use.\n- `direction`: `\"asc\" | \"desc\"` - The sort direction (ascending or descending).\n- `caseFirst`: `\"upper\" | \"lower\"` (optional, default: `\"upper\"`) - Whether upper case letters should be sorted before lower case letters (`\"upper\"`) or vice versa (`\"lower\"`).\n- `trimWhitespace`: `boolean` (optional, default: `false`) - Whether to trim whitespace from the beginning and end of each line before sorting.\n- `removeEmptyLines`: `boolean` (optional, default: `false`) - Whether to remove empty lines before sorting.\n- `removeDuplicateLines`: `boolean` (optional, default: `false`) - Whether to remove duplicate lines before sorting.\n\n## Usage\n\n### Example 1: Sorting Superheroes\n\n```typescript\nimport { sortLines, SortOptions } from \"textline-sorter\";\n\nconst superheros: string = `Thor\nAquaman\nCaptain America\nScarlet Witch\nBlack Panther\nAquaman\n\nScarlet Witch\n\nCyborg\n\nBlack Widow\n\nCaptain America\nDeadpool\nThe Flash\nSpider-Man\n\nBatman\nGreen Arrow\nWolverine\nGreen Arrow\nThe Flash`;\n\nconst options: SortOptions = {\n  order: \"alphabetical\",\n  direction: \"asc\",\n  removeEmptyLines: true,\n  removeDuplicateLines: true,\n};\n\nconst sortedSuperheros = sortLines(superheros, options);\nconsole.log(sortedSuperheros);\n```\n\nOutput:\n\n```\nAquaman\nBatman\nBlack Panther\nBlack Widow\nCaptain America\nCyborg\nDeadpool\nGreen Arrow\nScarlet Witch\nSpider-Man\nThe Flash\nThor\nWolverine\n```\n\nFor more examples, please refer to [/docs/USAGE.md](https://github.com/simonh1701/textline-sorter/blob/main/docs/USAGE.md).\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonh1701%2Ftextline-sorter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonh1701%2Ftextline-sorter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonh1701%2Ftextline-sorter/lists"}