{"id":15732601,"url":"https://github.com/jonschlinkert/sort-by-value","last_synced_at":"2025-03-13T04:31:18.729Z","repository":{"id":57366242,"uuid":"89553913","full_name":"jonschlinkert/sort-by-value","owner":"jonschlinkert","description":"Sort an array of objects by property value.","archived":false,"fork":false,"pushed_at":"2017-04-27T04:14:39.000Z","size":8,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-26T18:56:50.293Z","etag":null,"topics":["array","javascript","keys","nodejs","object","properties","sort","values"],"latest_commit_sha":null,"homepage":"https://github.com/jonschlinkert/sort-by-value","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/jonschlinkert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-27T03:58:24.000Z","updated_at":"2022-09-13T05:40:27.000Z","dependencies_parsed_at":"2022-08-23T19:31:00.533Z","dependency_job_id":null,"html_url":"https://github.com/jonschlinkert/sort-by-value","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fsort-by-value","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fsort-by-value/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fsort-by-value/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fsort-by-value/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/sort-by-value/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243341406,"owners_count":20275866,"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":["array","javascript","keys","nodejs","object","properties","sort","values"],"created_at":"2024-10-04T00:21:09.250Z","updated_at":"2025-03-13T04:31:18.068Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sort-by-value [![NPM version](https://img.shields.io/npm/v/sort-by-value.svg?style=flat)](https://www.npmjs.com/package/sort-by-value) [![NPM monthly downloads](https://img.shields.io/npm/dm/sort-by-value.svg?style=flat)](https://npmjs.org/package/sort-by-value)  [![NPM total downloads](https://img.shields.io/npm/dt/sort-by-value.svg?style=flat)](https://npmjs.org/package/sort-by-value) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/sort-by-value.svg?style=flat\u0026label=Travis)](https://travis-ci.org/jonschlinkert/sort-by-value)\n\n\u003e Re-order the objects in an array so that values of a specified property match the order of a provided array of values.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save sort-by-value\n```\n\nInstall with [yarn](https://yarnpkg.com):\n\n```sh\n$ yarn add sort-by-value\n```\n\n## Usage\n\n```js\nvar sortBy = require('sort-by-value');\nsortBy(array, {\n  prop: 'foo', // the property name to sort by\n  values: ['a', 'b', 'c'] // the property values to sort by\n});\n```\n\n## Example\n\n```js\nvar arr = [\n  {title: 'Foo'},\n  {title: 'Baz'},\n  {title: 'Bar'},\n  {title: 'Qux'},\n  {title: 'Faz'},\n  {title: 'Fez'}\n];\n\nvar res = sortBy(arr, {\n  prop: 'title',\n  values: ['Faz', 'Qux', 'Bar'],\n  normalize: function(val) {\n    return val;\n  }\n});\n\nconsole.log(res);\n// [ { title: 'Faz' },\n//   { title: 'Qux' },\n//   { title: 'Bar' },\n//   { title: 'Foo' },\n//   { title: 'Baz' },\n//   { title: 'Fez' } ]\n```\n\n## About\n\n### Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\nPlease read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.\n\n### Building docs\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n### Running tests\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n### Author\n\n**Jon Schlinkert**\n\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on April 27, 2017._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fsort-by-value","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Fsort-by-value","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fsort-by-value/lists"}