Código Javascript
:
Ver originalvar arr = ['P1', 'P6', 'P3', 'P4', 'P4', 'P6', 'P6'];
var a = [], b = [], prev;
arr.sort();
for ( var i = 0; i < arr.length; i++ ) {
if ( arr[i] !== prev ) {
a.push(arr[i]);
b.push(1);
} else {
b[b.length-1]++;
}
prev = arr[i];
}
for(x in a){
document.write(a[x]+" = "+b[x]+"</br>")
}