Angular 可怜的linq不工作了

Angular 可怜的linq不工作了,angular,linq,typescript,Angular,Linq,Typescript,我正在尝试使用LINQ对API的结果进行排序,但它不起作用 我希望网格中的行是基于主机名排序的,但我得到的是未排序的行 this.addservers=res.sortBy(x=>x.hostname) 我做错了什么 I think following should work. this.addservers = res.sort( function (x, y) { return x.hostname > y.hostname? 1 : 0; } ); I think fo

我正在尝试使用LINQ对API的结果进行排序,但它不起作用

我希望网格中的行是基于主机名排序的,但我得到的是未排序的行

this.addservers=res.sortBy(x=>x.hostname)

我做错了什么

I think following should work.

this.addservers = res.sort(
function (x, y) {
    return  x.hostname > y.hostname? 1 : 0;
}
);
I think following should work.

this.addservers = res.sort(
function (x, y) {
    return  x.hostname > y.hostname? 1 : 0;
}
);