按文本排序HtmlElements列表

现场可编程门阵列

我试图排序List<HtmlElement>通过Text,文本被解析为num

 this.onClick.listen((e){
     this.parent.nextElementSibling.children.sort((Row a,Row b)=>
         num.parse(a.children[this.visibleIndex].text).
         compareTo(num.parse(b.children[this.visibleIndex].text)));
    });   

Row 是延伸的课程 HtmlElement

我得到了例外

Unsupported operation: Cannot sort element lists

是否有解决方法,还是我必须手动进行?

贡特·佐赫鲍尔(GünterZöchbauer)

我还没有尝试过,但是我认为添加后它应该可以工作.toList()我认为这应该将其复制到可排序的标准列表中。

 this.onClick.listen((e){
     this.parent.nextElementSibling.children.toList().sort((Row a,Row b)=>
         num.parse(a.children[this.visibleIndex].text).
         compareTo(num.parse(b.children[this.visibleIndex].text)));
    });   

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章