test
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • Mr.Cat Moderator
    #1067116

    Hi @darebee,

    It’s a bug of megafilter. Thanks for reporting us.

    To fix it, please open file

    /components/com_jamegafilter/assets/js/megafilter.js

    Find this line

    if (self.sortField) {

    And replace all content of scope below with this

    var v1 = self.getItem(a).getField(self.sortField),
        v2 = self.getItem(b).getField(self.sortField);
    
    // transfer array to string
    if (Array.isArray(v1)) {
        v1.sort();
        v1 = v1.join(' ');
    }
    if (Array.isArray(v2)) {
        v2.sort();
        v2 = v2.join(' ');
    }
    
    if (v1 == v2) {
        var t1 = +self.getItem(a).getField('id'),
            t2 = +self.getItem(b).getField('id');
        return t1 > t2 ? d : -d;
    }
    
    if ( !isNaN(v1) && !isNaN(v2) ) {
        v1 = +v1;
        v2 = +v2;
    } else if( v1 && v2 ) {
        v1 = v1.split('');
        v2 = v2.split('');
        var min = Math.min(v1.length, v2.length);
        for (var i = 0; i < min; i++) {
            if (v1 != v2) {
                return v1.localeCompare(v2) > 0 ? d : -d;
            }
        }
    }
    
    return v1 > v2 ? d : -d;

    This fix will be included also for the upcoming release.

    Regards

    Wisdom is not a product of schooling but of the lifelong attempt to acquire it.

    darebee Friend
    #1067271

    Thank you so much!!!!! It works perfectly!!!!

Viewing 2 posts - 1 through 2 (of 2 total)

This topic contains 2 replies, has 2 voices, and was last updated by  darebee 7 years, 1 month ago.

The topic ‘Sorting items bug’ is closed to new replies.