Notably, none of the answers given (despite being clever solutions to get the data) output the exact format requested. [("..",..),...]
The input string is quoted, so the output appears to be an array (not a string type).
My stab at it in Javascript resulted in:
function collapse(a) {
collapsedArray = [];
for (let i=0; i
This outputs `[["a",2],["b",2],["c",1],["d",2],["e",1]]`. Without native tuples in Javascript (or JSON), I could construct a string which replaces the inner brackets with parens, but that would be pretty contrived, as the output requested isn't quoted.