generic/py-backend/fs_utils/list_dir.py
def _file_comparator(a_file, b_file):
    """
    Comparator for sorting files list.
    Sorting order ensures that printing the list gives us in a tree-like representation:
    - dir1
    - dir1/nested_dir1
    - dir1/nested_dir1/very_nested_dir1
    - dir1/nested_file1
    - dir2
    - file1
    - ...

    Rules:
    - directories have priority over files at the same level
    - nested directories and files must follow parent directory
      (before any parent's siblings)
    """
    if a_file["dir_name"] == b_file["dir_name"]:
        return _same_dir_file_comparator(a_file, b_file)

    return _diff_dir_file_comparator(a_file, b_file)

    Comparator for sorting files list.
    Sorting order ensures that printing the list gives us in a tree-like representation:
    - dir1
    - dir1/nested_dir1
    - dir1/nested_dir1/very_nested_dir1
    - dir1/nested_file1
    - dir2
    - file1
    - ...

    Rules:
    - directories have priority over files at the same level
    - nested directories and files must follow parent directory
      (before any parent's siblings)
    
Comparator for sorting files list.
Sorting order ensures that printing the list gives us in a tree-like representation:
dir1
dir1/nested_dir1
dir1/nested_dir1/very_nested_dir1
dir1/nested_file1
dir2
file1

directories have priority over files at the same level
nested directories and files must follow parent directory
(before any parent's siblings)
Comparator for sorting files list . Sorting order ensures that printing the list gives us in a tree - like representation : dir1 dir1 / nested_dir1 dir1 / nested_dir1 / very_nested_dir1 dir1 / nested_file1 dir2 file1 directories have priority over files at the same level nested directories and files must follow parent directory ( before any parent ' s siblings )
def _file_comparator(a_file, b_file):
    if a_file["dir_name"] == b_file["dir_name"]:
        return _same_dir_file_comparator(a_file, b_file)
    return _diff_dir_file_comparator(a_file, b_file)
def _file_comparator ( a_file , b_file ) : if a_file [ "dir_name" ] == b_file [ "dir_name" ] : return _same_dir_file_comparator ( a_file , b_file ) return _diff_dir_file_comparator ( a_file , b_file )
Comparator for sorting files list.
Comparator for sorting files list .
"""
    Comparator for sorting files list.
    Sorting order ensures that printing the list gives us in a tree-like representation:
    - dir1
    - dir1/nested_dir1
    - dir1/nested_dir1/very_nested_dir1
    - dir1/nested_file1
    - dir2
    - file1
    - ...

    Rules:
    - directories have priority over files at the same level
    - nested directories and files must follow parent directory
      (before any parent's siblings)
    """
a_file
b_file