具有升序和降序混合的同位素多重排序

Isotope multi-sort with a mixture of ascending and descending

我正在使用 Isotope jQuery plugin to sort some tabular data. That's all working fine, but now I need to sort on multiple columns, which is documented

问题是某些列需要升序排序,而其他列则需要降序排序。根据文档,同位素通过设置一组值和这些值的方向来工作,而不是两者的混合。见下文:

var $container = $('#multiple-sort-by .isotope').isotope({
  // sort by color then number
  sortBy: [ 'color', 'number' ],
  sortAscending: true
});

可以吗?

我期望的语法可能是:

var $container = $('#multiple-sort-by .isotope').isotope({
  // sort by color then number
  sortBy: {
      [ 'color', 'asc' ],
      [ 'number', 'desc' ],
  }
});

我找到了概述如何执行此操作的文档的不同区域。您可以向 sortAscending.

提供一个对象,而不是我建议的语法

EG:

$container.isotope({ 
    sortBy: sortValue,
    sortAscending: {
        color: true,
        number: false,
    }
});