code: def test_dir_hash_should_be_key_order_agnostic(tmp_dir, dvc, mocker):
      from dvc_data.hashfile.build import build
      from dvc_data.hashfile.tree import Tree
  
      tmp_dir.gen({"data": {"1": "1 content", "2": "2 content"}})
  
      path = (tmp_dir / "data").fs_path
  
      tree = Tree.from_list(
          [{"relpath": "1", "md5": "1"}, {"relpath": "2", "md5": "2"}]
      )
      tree.digest()
  
      mocker.patch(
          "dvc_data.hashfile.build._build_tree",
          return_value=(None, tree),
      )
  
      _, _, obj = build(
          dvc.cache.local, path, dvc.cache.local.fs, "md5"
      )
      hash1 = obj.hash_info
  
      # remove the raw dir obj to force building the tree on the next build call
      dvc.cache.local.fs.remove(
          dvc.cache.local.oid_to_path(hash1.as_raw().value)
      )
  
      tree = Tree.from_list(
          [{"md5": "1", "relpath": "1"}, {"md5": "2", "relpath": "2"}]
      )
      tree.digest()
  
      # NOTE: _build_tree already patched above
      _, _, obj = build(
          dvc.cache.local, path, dvc.cache.local.fs, "md5"
      )
      hash2 = obj.hash_info
  
      assert hash1 == hash2
  
imports: import errno
  import itertools
  import os
  import stat
  import configobj
  import pytest
  from dvc.cli import main
  from dvc.config import Config
  from dvc.exceptions import DownloadError, UploadError
  from dvc.utils.fs import remove
label_desc: Use image node_id 10 for calling a global function with example usage: test_dir_hash_should_be_key_order_agnostic(tmp_dir, dvc, mocker) without return types