{"id":21698552,"url":"https://github.com/luizfelipelopes/grouping-transactions-by-items-names","last_synced_at":"2026-04-17T00:02:29.933Z","repository":{"id":225586645,"uuid":"766347886","full_name":"luizfelipelopes/Grouping-Transactions-by-Items-Names","owner":"luizfelipelopes","description":"Grouping Transactions by Items'Names (Wanderlog Assesments)","archived":false,"fork":false,"pushed_at":"2024-03-03T02:35:03.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-20T15:23:14.490Z","etag":null,"topics":["algorithm","algorithm-challenges","algorithms","algorithms-and-data-structures","assessment","javascript"],"latest_commit_sha":null,"homepage":"https://stackblitz.com/edit/vitejs-vite-edfvan","language":"CSS","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/luizfelipelopes.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}},"created_at":"2024-03-03T02:19:09.000Z","updated_at":"2024-03-03T02:36:51.000Z","dependencies_parsed_at":"2024-03-03T03:25:47.351Z","dependency_job_id":"3d1c2b15-2a91-4747-b015-46eb603f9809","html_url":"https://github.com/luizfelipelopes/Grouping-Transactions-by-Items-Names","commit_stats":null,"previous_names":["luizfelipelopes/grouping-transactions-by-items-names"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/luizfelipelopes/Grouping-Transactions-by-Items-Names","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizfelipelopes%2FGrouping-Transactions-by-Items-Names","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizfelipelopes%2FGrouping-Transactions-by-Items-Names/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizfelipelopes%2FGrouping-Transactions-by-Items-Names/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizfelipelopes%2FGrouping-Transactions-by-Items-Names/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luizfelipelopes","download_url":"https://codeload.github.com/luizfelipelopes/Grouping-Transactions-by-Items-Names/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizfelipelopes%2FGrouping-Transactions-by-Items-Names/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31909235,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"ssl_error","status_checked_at":"2026-04-16T18:21:47.142Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["algorithm","algorithm-challenges","algorithms","algorithms-and-data-structures","assessment","javascript"],"created_at":"2024-11-25T19:35:02.084Z","updated_at":"2026-04-17T00:02:29.798Z","avatar_url":"https://github.com/luizfelipelopes.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Grouping Transactions by Items'Names (Wanderlog Assesments)\n\nProblem resolved in Wanderlog Assesments for Software Engineer role.\n\n### Problem\nFor a given array of transactions, group all of the transactions by item name. Return an array of strings where each string contains the item name followed by a space and the number of associated transactions.\n\n**Note:** Sort the array descending by transaction count, then ascending alphabetically by item name for items with matching transaction counts.\n\n**Example:**\n\n*transactions = ['notebook', 'notebook', 'mouse', 'keyboard', 'mouse']*\n\nThere are two items with 2 transactions each: 'notebook' and 'mouse'. In alphabetical order, they are 'mouse', 'notebook'.\n\nThere is one item with 1 transaction: 'keyboard'.\n\nThe return array, sorted as required, is ['mouse 2', 'notebook 2', 'keyboard 1'].\n\n**Function Description**\n\nComplete the function groupTransactions in the editor below.\n\ngroupTransactions has the following parameter(s):\n\n* *string transactions[n]: each transactions[i] denotes the item name in the i^th^ transaction*\n\nReturns:\n\n* *string[]: an array of strings of \"item name[space]transaction count\" sorted as described*\n\n**Constraints:**\n\n* *1 ≤ n ≤ 10^5^*\n* *1 ≤ length of transactions[i] ≤ 10*\n* *transactions[i] contains only lowercase English letters, ascii[a-z]*\n\n**Input Format for Custom Testing**\n\nInput from stdin will be processed as follows and passed to the function.\n\n* The first line contains a single integer, n, the size of transactions.\n* Each of the next n lines contains a string, the item name for transactions[i].\n\n### Sample Case 1\n\nSample Input\n\n```\nSTDIN     Function\n-----     -----\n4      →  transactions[] size n = 4\nbin    →  transactions = ['bin', 'can', 'bin', 'bin']\ncan\nbin\nbin\n```\n\nSample Output\n\n```\nbin 3\ncan 1\n```\n\n**Explanation:**\n\n* *There is one item 'bin' with 3 transactions.*\n* *There is one item 'can' with 1 transaction.*\n* *The return array sorted descending by transaction count, then ascending by name is ['bin 3', 'can 1'].*\n\n\n### Sample Case 2\n\nSample Input\n\n```\nSTDIN     Function\n-----     -----\n3      →  transactions[] size n = 3\nbanana →  transactions = ['banana', 'pear', 'apple']\npear\napple\n```\n\nSample Output\n\n```\napple 1\nbanana 1\npear 1\n```\n\n**Explanation:**\n\n* *There is one item 'apple' with 1 transaction.*\n* *There is one item 'banana' with 1 transaction.*\n* *There is one item 'pear' with 1 transaction.*\n* *The return array sorted descending by transaction count, then ascending by name is ['apple 1', 'banana 1', 'pear 1'].*","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluizfelipelopes%2Fgrouping-transactions-by-items-names","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluizfelipelopes%2Fgrouping-transactions-by-items-names","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluizfelipelopes%2Fgrouping-transactions-by-items-names/lists"}