For a given array of transactions, group all of the transactions by item name. Return an array
Fantastic news! We've Found the answer you've been seeking!
Question:
For 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. Note: Sort the array descending by transaction count, then ascending alphabetically by item name for items with matching transaction counts. Example transactions = ['notebook', 'notebook', 'mouse', 'keyboard, 'mouse'] 22 23 24 There are two items with 2 transactions each: 'notebook' and 'mouse! In alphabetical order, they are ' mouse' 'notebook. There is one item with 1 transaction: 'keyboard'. The return array, sorted as required, is ['mouse 2', 'notebook 2', 'keyboard 1'].
Posted Date: