Different results when changing pipeline aggregations order

Consider this query:

GET test-index/_search
{
  "size": 0, 
   "query": {
      "term": {
        "data.category": {
          "value": "light"
        }
      }
   }
   , "aggs": {
     "brand_model": {
       "terms": {"field": "data.brand", "size": 1000, "order": {
         "sort_date": "desc"
       }},
       "aggs": {
         "sort_date": {
           "max": {
             "field": "sort_date"
            }
         },
          "sort_date_bucket_filter": {
            "bucket_selector": {
                "buckets_path": {
                  "sort_date": "sort_date.value"
                },
                "script": "1.584896296672E12 > params.sort_date"
            }
          },
           "sort_date_bucket_sort": {
            "bucket_sort": {
                "sort": [{
                  "sort_date": {"order": "desc"}
                }],
                "size": 10,
                "from": 0
              }
          }
       }
     }
   }
}

And when i chenge the order of pipeline aggregations to this:

GET test-index/_search
{
  "size": 0, 
   "query": {
      "term": {
        "data.category": {
          "value": "light"
        }
      }
   }
   , "aggs": {
     "brand_model": {
       "terms": {"field": "data.brand", "size": 1000, "order": {
         "sort_date": "desc"
       }},
       "aggs": {
         "sort_date": {
           "max": {
             "field": "sort_date"
            }
         },
         "sort_date_bucket_sort": {
            "bucket_sort": {
                "sort": [{
                  "sort_date": {"order": "desc"}
                }],
                "size": 10,
                "from": 0
              }
          },
          "sort_date_bucket_filter": {
            "bucket_selector": {
                "buckets_path": {
                  "sort_date": "sort_date.value"
                },
                "script": "1.584896296672E12 > params.sort_date"
            }
          }
       }
     }
   }
}

the result i get is empty (different result!).
Can anyone explain this? Does ordering has any effect on the aggregations result?