jquery array sort

var sort_by = function (field, reverse, primer) {
        var key = primer ?
            function (x) { return primer(x[field]) } :
            function (x) { return x[field] };
        reverse = !reverse ? 1 : -1;
        return function (a, b) {
            return a = key(a), b = key(b), reverse * ((a > b) – (b > a));
        }
    }
    $(‘body’).on(‘click’, ‘#checkEtiketAlici’, function (event) {
        $(‘#checkEtiketAlici’).prop(‘checked’, true);
        $(‘#checkEtiketSiparisNo’).prop(‘checked’, false);
        aktarilanlarDataList.sort(sort_by(‘CH_ALICI_ADI’, false, function (a) { return a.toUpperCase() }));
    });
    $(‘body’).on(‘click’, ‘#checkEtiketSiparisNo’, function (event) {
        $(‘#checkEtiketAlici’).prop(‘checked’, false);
        $(‘#checkEtiketSiparisNo’).prop(‘checked’, true);
        aktarilanlarDataList.sort(sort_by(‘CH_REFERANS_ID’, false, parseInt));
    });
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: