{"id":20962988,"url":"https://github.com/doesdev/leven-sort","last_synced_at":"2025-05-14T08:34:40.967Z","repository":{"id":58223088,"uuid":"56100973","full_name":"doesdev/leven-sort","owner":"doesdev","description":"Simply sort by similarity, starring Levenshtein via leven","archived":false,"fork":false,"pushed_at":"2022-08-20T03:02:51.000Z","size":85,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-08T01:08:16.908Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/doesdev.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":"2016-04-12T22:02:40.000Z","updated_at":"2024-09-18T14:13:59.000Z","dependencies_parsed_at":"2022-08-31T03:00:42.131Z","dependency_job_id":null,"html_url":"https://github.com/doesdev/leven-sort","commit_stats":null,"previous_names":["musocrat/leven-sort"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doesdev%2Fleven-sort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doesdev%2Fleven-sort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doesdev%2Fleven-sort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doesdev%2Fleven-sort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doesdev","download_url":"https://codeload.github.com/doesdev/leven-sort/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254105130,"owners_count":22015597,"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-11-19T02:39:45.964Z","updated_at":"2025-05-14T08:34:38.726Z","avatar_url":"https://github.com/doesdev.png","language":"JavaScript","readme":"# leven-sort   [![npm version](https://badge.fury.io/js/leven-sort.svg)](http://badge.fury.io/js/leven-sort)   [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)   [![Dependency Status](https://dependencyci.com/github/doesdev/leven-sort/badge)](https://dependencyci.com/github/doesdev/leven-sort)\n\nSimply sort by similarity, starring Levenshtein via [leven](https://github.com/sindresorhus/leven).\n\nAllows sorting of an array of strings or array of objects by similarity. For arrays of objects\nyou can sort by up to two keys.\n\n## install\n`npm i leven-sort --save`\n\n## api\n\n**leven-sort** only exports one function, but it has 3 distinct signatures\n\n1. Sort simple text array  \n`arrayToSort`: Array to sort (sorted in place)   \n`sourceText`: The text to check similarity of\n\n2. Sort array of objects, with optional secondary sort\n`arrayToSort`: Array to sort (sorted in place)   \n`sourceText1`: The text to check similarity of   \n`key1`: Property name to be compared in each object   \n`sourceText2` *(optional)*: If performing a secondary sort, this is the text to check key2 by  \n`key2` *(optional)*: For secondary sort on object, this is the second property to check   \n\n3. Sort array of objects by multiple keys, each by the same source and with equal weight  \n`arrayToSort`: Array to sort (sorted in place)   \n`sourceText`: The text to check similarity of   \n`arrayOfKeys`: Array of property names to compare    \n\n## usage\n\nSort simple text array\n```javascript\nconst levenSort = require('leven-sort')\nconst sourceName = 'Bill Griffin'\nconst nameAry = [\n  'Carl Martinez',\n  'Roger Davis',\n  'William George',\n  'Andrew Torres',\n  'Billy Campbell',\n  'Alan King',\n  'Benjamin Wilson',\n  'Bill Griffin',\n  'Dennis Smith',\n  'Billy Griffith'\n]\nlet levSorted = levenSort(nameAry, sourceName)\n```\n\nSort array of objects, with secondary sort\n```javascript\nconst levenSort = require('leven-sort')\nconst sourceFirst = 'Bill'\nconst sourceLast = 'Griffin'\nconst nameObjAry = [\n  { first: 'Carl', last: 'Martinez' },\n  { first: 'Roger', last: 'Davis' },\n  { first: 'William', last: 'George' },\n  { first: 'Andrew', last: 'Torres' },\n  { first: 'Billy', last: 'Campbell' },\n  { first: 'Alan', last: 'King' },\n  { first: 'Benjamin', last: 'Wilson' },\n  { first: 'Bill', last: 'Griffin' },\n  { first: 'Dennis', last: 'Smith' },\n  { first: 'Billy', last: 'Griffith' }\n]\n\nlet levSorted = levenSort(nameObjAry, sourceFirst, 'first', sourceLast, 'last')\n\n```\n\nSort array of objects by multiple keys\n```javascript\nconst levenSort = require('leven-sort')\nconst source = 'Bill'\nconst nameObjAry = [\n  { first: 'Carl', last: 'Martinez' },\n  { first: 'Roger', last: 'Davis' },\n  { first: 'William', last: 'George' },\n  { first: 'Andrew', last: 'Torres' },\n  { first: 'Billy', last: 'Campbell' },\n  { first: 'Alan', last: 'King' },\n  { first: 'Benjamin', last: 'Wilson' },\n  { first: 'Bill', last: 'Griffin' },\n  { first: 'Dennis', last: 'Smith' },\n  { first: 'Billy', last: 'Griffith' }\n]\n\nlet levSorted = levenSort(nameObjAry, source, ['first', 'last'])\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoesdev%2Fleven-sort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoesdev%2Fleven-sort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoesdev%2Fleven-sort/lists"}