Is there any way to perform 2 different pipeline aggregation on a bucket aggregation

Hi,

I have created an elasticsearch aggregation with some heavy operation like script. Now I want to perform 2 different bucket sort on the result of the aggregation I did earlier. Is there any way I can do that?

I know I can write 2 aggreagtions but I want to avoid doing same initial aggregation twice for 2 different result.

It'd be better if you can share the query, what you have tried so far, and the expected results.