{"id":21145351,"url":"https://github.com/jsa2/arraygroupitems","last_synced_at":"2026-04-21T20:34:09.504Z","repository":{"id":103264033,"uuid":"440411245","full_name":"jsa2/arrayGroupItems","owner":"jsa2","description":null,"archived":false,"fork":false,"pushed_at":"2021-12-21T06:43:04.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"public","last_synced_at":"2026-01-02T00:54:56.388Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsa2.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2021-12-21T06:17:18.000Z","updated_at":"2021-12-21T06:43:06.000Z","dependencies_parsed_at":"2023-03-13T15:08:51.975Z","dependency_job_id":null,"html_url":"https://github.com/jsa2/arrayGroupItems","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jsa2/arrayGroupItems","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsa2%2FarrayGroupItems","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsa2%2FarrayGroupItems/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsa2%2FarrayGroupItems/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsa2%2FarrayGroupItems/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsa2","download_url":"https://codeload.github.com/jsa2/arrayGroupItems/tar.gz/refs/heads/public","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsa2%2FarrayGroupItems/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32108766,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-21T11:25:29.218Z","status":"ssl_error","status_checked_at":"2026-04-21T11:25:28.499Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":[],"created_at":"2024-11-20T08:39:39.604Z","updated_at":"2026-04-21T20:34:09.478Z","avatar_url":"https://github.com/jsa2.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\r\n# Data grouping tool\r\n\r\nThere is likely multiple libraries to do this same thing, I did this mostly for fun, and since I need to customize sorting to certain output type very often.\r\n\r\n✅ Data output and input is expected to be JSON\r\n\r\n✅ Tool will add group and items object to each group\r\n\r\n![image](https://user-images.githubusercontent.com/58001986/146882914-5a1e0695-ae78-463a-b976-c91953cc0ef8.png)\r\n\r\n\r\n```JS\r\n{\r\n  group: \"Kumpula\",\r\n  items: [\r\n    [\r\n      {\r\n        group: \"sports\",\r\n        items: [\r\n          {\r\n              \"......\":\".....\"\r\n          },\r\n        ],\r\n      },\r\n    ],\r\n  ],\r\n}\r\n```\r\n\r\n## Example using https://open-api.myhelsinki.fi/\r\n\r\n## How to use\r\n1. Make the sortable data available in single level (Node.JS array.map() is handy for this\r\n2. Decide grouping criteria\r\n\r\n```js\r\nconst { newSet } = require(\"./helpers/grouping\");\r\nconst { httpP } = require(\"./helpers/httpabstract\");\r\n\r\nmain()\r\n\r\nasync function main () {\r\n\r\n    var data = await httpP('http://open-api.myhelsinki.fi/v2/places/').catch((error) =\u003e {\r\n        console.log(error)\r\n    })\r\n\r\nvar places = JSON.parse(data)\r\n\r\n    // make sortable data \"flat\"\r\n    places.data.map(place =\u003e {\r\n        //console.log(place)\r\n        place.postal = place.location.address.postal_code\r\n        place.neighbourhood = place.location.address.neighbourhood\r\n        place.tag = place.tags[0].name\r\n    })\r\n\r\n    // Additional sort for post number\r\n    var sortedSet = newSet(places.data, ['postal','neighbourhood','tag']).sort((a,b) =\u003e {\r\n\r\n        if (a.group \u003c b.group) {\r\n            return -1\r\n        } else {\r\n            return 1\r\n        }\r\n\r\n    })\r\n    console.log(sortedSet)\r\n}\r\n\r\n```\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsa2%2Farraygroupitems","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsa2%2Farraygroupitems","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsa2%2Farraygroupitems/lists"}