harold, сортировка не нужна
function StatOfArr(A)
{
var n = A.length, B = [], b = 0;
for (var i = 0; i < n; i++)
{ var k = 0, count = 1;
while (k < b && B[k][0] !== A[i]) k++;
if (k === b)
{ for (var j = i+1; j < n; j++){ if (A[i] === A[j]) count++; }
B[b++] = [A[i],count];
}
}
return B;
}
var arr = [2, 7, 5, 1, 'a', 5, 2, 2, 'a', 'a', 7, 0];
alert( '[['+StatOfArr(arr).join('], [')+']]' );