{"id":20393096,"url":"https://github.com/aichbauer/node-array-table-sort","last_synced_at":"2026-04-15T20:31:31.774Z","repository":{"id":31349507,"uuid":"127617898","full_name":"aichbauer/node-array-table-sort","owner":"aichbauer","description":"Sort an array (asc, desc) that holds data for tables","archived":false,"fork":false,"pushed_at":"2022-12-09T08:24:10.000Z","size":1249,"stargazers_count":0,"open_issues_count":12,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-04T08:57:23.268Z","etag":null,"topics":["array","asc","desc","filter","list","nodejs","sort","table"],"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/aichbauer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2018-04-01T10:08:41.000Z","updated_at":"2020-11-04T18:00:30.000Z","dependencies_parsed_at":"2023-01-14T18:51:17.720Z","dependency_job_id":null,"html_url":"https://github.com/aichbauer/node-array-table-sort","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/aichbauer/node-array-table-sort","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aichbauer%2Fnode-array-table-sort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aichbauer%2Fnode-array-table-sort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aichbauer%2Fnode-array-table-sort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aichbauer%2Fnode-array-table-sort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aichbauer","download_url":"https://codeload.github.com/aichbauer/node-array-table-sort/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aichbauer%2Fnode-array-table-sort/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31859200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"ssl_error","status_checked_at":"2026-04-15T15:24:39.138Z","response_time":63,"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":["array","asc","desc","filter","list","nodejs","sort","table"],"created_at":"2024-11-15T03:47:28.122Z","updated_at":"2026-04-15T20:31:31.757Z","avatar_url":"https://github.com/aichbauer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# array-table-sort\n\n[![npm](https://img.shields.io/npm/v/array-table-sort.svg?style=flat-square)](https://www.npmjs.com/package/array-table-sort)\n[![Travis branch](https://img.shields.io/travis/aichbauer/node-array-table-sort/master.svg?style=flat-square)](https://travis-ci.org/aichbauer/node-array-table-sort)\n[![Codecov branch](https://img.shields.io/codecov/c/github/aichbauer/node-array-table-sort/master.svg?style=flat-square)](https://codecov.io/gh/aichbauer/node-array-table-sort)\n\n\u003e Sort an array (asc, desc) that holds data for tables\n\n## Table of Contents\n\n* [Why?](#why)\n* [Installation](#installation)\n* [Functions](#functions)\n* [Usage](#usage)\n* [License](#license)\n\n## Why?\n\nI wanted to have a simple way to sort a table component in react.\n\n## Installation\n\n```sh\n$ npm i array-table-sort -S\n```\n\nor\n\n```sh\n$ yarn add array-table-sort\n```\n\n## Functions\n\nTake a look into the [usage section](#usage) for a detailed example.\n\n### sortArrayByKey\n\nThis function can sort on object keys (one row).\n\n#### Syntax\n\nReturns a new array.\n\n```js\nconst sortedArray = sortArrayByKey(data, options);\n```\n\n##### Parameters\n\n* **data**: an array of object\n  * each object represents one row\n  * each key of one object has to be the name of the column\n  * each value of a key of one object is the value of the cell in the table\n* **options**: an object\n  * the keys in that object has to be the name of the column + one key active\n  * the active key holds name the current column to sort\n  * each other key holds another object with one key (asc)\n  * asc equals true if the array is sorted ascending and false if descending\n\n### searchArrayTable\n\nThis function can filter (search) on the complete object (one row).\nIf one key value filter is `true` the object (row) is in the returned data set.\n\n## Usage\n\nAn example how to use it.\n\n```js\nconst { sortArrayByKey } = require('array-table-sort');\n\n/*\n  the data that is contained in the table\n  each row represented by an object\n  each column represented by the keys used in the objects\n*/\nconst data = [\n  {\n    number: 1,\n    first: 'Mark',\n  },\n  {\n    number: 2,\n    first: 'Jacob',\n  },\n  {\n    number: 3,\n    first: 'Larry',\n  },\n];\n\n/*\n  the active key holds the current column to sort\n  each column has a key asc\n  the active key and the asc usually change on an event (e.g. button click etc)\n*/\nconst sortOptions = {\n  active: 'first',\n  number: {\n    asc: false,\n  },\n  first: {\n    asc: true,\n  },\n};\n\n/*\n  returns a new array\n\n  const sortedTable = [\n    {\n      number: 2,\n      first: 'Jacob',\n    },\n    {\n      number: 3,\n      first: 'Larry',\n    },\n    {\n      number: 1,\n      first: 'Mark',\n    },\n  ];\n*/\nconst sortedTable = sortArrayByKey(data, sortOptions);\n```\n\n## License\n\nMIT © Lukas Aichbauer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faichbauer%2Fnode-array-table-sort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faichbauer%2Fnode-array-table-sort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faichbauer%2Fnode-array-table-sort/lists"}