Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // http://prohardver.hu/tema/javascript_topic/hsz_3701-3701.html
- Array.prototype.indexesOfGreatestNums = function () {
- var result = new String,
- a = new Array,
- b = new Array;
- c = new Array;
- a[0] = 0, b[0] = 0;
- for (var i = 0, j = 0; i < this.length; i++) {
- if (this[i] > 0) {
- if (a.indexOf(this[i].toString()) >= 0) {
- if (b[a.indexOf(this[i].toString())] !== undefined) {
- b[a.indexOf(this[i].toString())]++
- } else {
- b[a.indexOf(this[i].toString())] = 1;
- };
- } else {
- a[j] = this[i];
- if (b[j] !== undefined) {
- b[j]++
- } else {
- b[j] = 1
- };
- j++;
- }; //end else
- }; // end if
- }; // end for
- //var ok = popup('',a + '\n' + b,false,'','',30);
- var that = this.slice(0);
- for (i = 0; i < a.length; i++) {
- for (j = 0; j < b[a.indexOf(Math.max.apply('', a).toString())]; j++) {
- //flash(that.join() +'\n'+ a.join());
- c[j] = that.indexOf(Math.max.apply('', a).toString());
- that[that.indexOf(Math.max.apply('', a).toString())] = 0;
- }; //end for
- result = result + c.join() + '>';
- c = [];
- a[a.indexOf(Math.max.apply('', a).toString())] = 0;
- }; // end for
- return (result);
- }; // end prototype
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement