Broken pipe & Connection closed by peer в SphinxClient::UpdateAttributes() [PHP] IE6 и DOM appendChild на лету..
Mar 02

Накидал простенькую ф-ию для сортировки хешей (associative arrays)  по значению. Все примитивно и тюнится под свои нужды :)

<script>
    function asort(arr) {
        var numArr = new Array; // values
        var map = new Array;    // index => values array
        var out = new Array;

        for(k in arr) {
            numArr[numArr.length] = arr[k];
            if(map[arr[k]] == undefined) map[arr[k]] = new Array;
            map[arr[k]].push(k);
        }
        numArr.sort( function(a, b) { return (b-a); } ); //desc

        for(var i=0; i<numArr.length; i++) {
            for(var j=0; j<map[numArr[i]].length; j++) {
                out[map[numArr[i]][j]] = numArr[i];
            }
        }
        return out;
    }
</script>

Related posts:

  1. Простой JS фильтр ввода в поле формы по опр. значениям.

Leave a Reply

This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)

You must read and type the 5 chars within 0..9 and A..F, and submit the form.

  

Oh no, I cannot read this. Please, generate a