/* Will count all equal array entries and list them in a javascript object such that there is a object property for each unique array entry. The value of that property equals the number of occurences. The order of the properties is sorted according to the number of occurences. With the most occurences first. You can use this construct for(var key in obj) { console.log(obj[key]); } to iterate over all items in sorted order. */ function countElements(array) { var tmp = {}; var result = {}; var helpArray = []; for(var i=0; i 1) { for(var i=1; i