Typescript 您如何对可观察到的<;第[]项>;使用rxjs 6的角度6?

Typescript 您如何对可观察到的<;第[]项>;使用rxjs 6的角度6?,typescript,angular6,rxjs6,Typescript,Angular6,Rxjs6,我只想对我的类类型“Category”的可观察对象上的数据进行排序。所以我想对可观察的进行排序 所以我用它升级到Angular6和rxjs6。我知道的一个问题可能是简单的Typescript,那就是如何执行“排序”操作,如: sort((x,y) => x.description < y.description ? -1 : 1) sort((x,y)=>x.description此.按字母顺序排列(结果)); 字母顺序=(result:Response)=>this.Catego

我只想对我的类类型“Category”的可观察对象上的数据进行排序。所以我想对可观察的进行排序

所以我用它升级到Angular6和rxjs6。我知道的一个问题可能是简单的Typescript,那就是如何执行“排序”操作,如:

sort((x,y) => x.description < y.description ? -1 : 1)
sort((x,y)=>x.description
新Angular6的内部?我过去常在5分钟内做这件事

var response = this.http.get<Category[]>(this.endpoint);
        .map((result: Response) => this.alphabetize(result));


alphabetize = (result: Response) => this.Categories = result.json()
.sort((x,y) => x.description < y.description ? -1 : 1)
var response=this.http.get(this.endpoint);
.map((结果:响应)=>此.按字母顺序排列(结果));
字母顺序=(result:Response)=>this.Categories=result.json()
.sort((x,y)=>x.description
而且效果很好。现在在HttpCLIENTModule和HttpClient中,Angular希望您使用它更简单:

var data = this.http.get<Category[]>(this.endpoint);
var data=this.http.get(this.endpoint);
我只是把魔术放在我的终点之前,它为我做到了。酷。但是我没有看到你是如何进入对象内部的,很容易从它的来源,管道,来源,等等进行排序的。我知道它可能很简单,只是我不知道它的语法。

它是:

this.http.get<Category[]>(this.endpoint).pipe(
  map(results => results.sort(...))
);

在这种情况下,它们也应该起类似的作用。但很高兴它起作用了。
this.http.get<Category[]>(this.endpoint).pipe(
  tap(results => {
    results.sort()
  })
);