Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javascript根据它对地图进行排序';s属性和返回映射_Javascript_Canjs - Fatal编程技术网

javascript根据它对地图进行排序';s属性和返回映射

javascript根据它对地图进行排序';s属性和返回映射,javascript,canjs,Javascript,Canjs,我正在尝试对过滤器中的贴图进行排序并返回贴图 var sort = this.attr('component').attr('sort'); if (sort == 'Price Descending') { return this.attr('%root.products').filter(function(product) { // How can I sort 'product' here before returning?

我正在尝试对过滤器中的贴图进行排序并返回贴图

  var sort = this.attr('component').attr('sort');
  if (sort == 'Price Descending')
  {
     return this.attr('%root.products').filter(function(product) {
            // How can I sort 'product' here before returning? 
            return (product.attr(product.attr('active') !== 'f';
     });
  }
如上所述,在返回和比较产品回调变量之前,如何对其进行排序


任何帮助都将不胜感激。

这基本上是一个映射,它被过滤到一个数组,这是一个映射,它返回一个已解决的承诺
prodcut.attr('price')
包含价格,我需要在返回itI之前对其进行向下排序。我看不出
attr()
如何返回字符串以外的任何内容。如果
this
是jQuery对象,
attr()
返回一个字符串
this
是一个映射,即视图模型,由属性范围内的
var self=this
接收。这与jQuery无关,正如OP标题和标记中所指出的