def order_paths(paths_to_order, prefix_paths):
    # the ordered paths contains a list for each prefix plus one more which contains paths which do not match one of the prefix_paths
    ordered_paths = [[] for _ in range(len(prefix_paths) + 1)]

    for path in paths_to_order:
        # put each directory into the slot where it matches the prefix, or last otherwise
        index = 0
        for prefix in prefix_paths:
            if path == prefix or path.startswith(prefix + os.sep) or (os.altsep and path.startswith(prefix + os.altsep)):
                break
            index += 1
        ordered_paths[index].append(path)

    # flatten list of lists
    return [j for i in ordered_paths for j in i]
Return a list containing all items of paths_to_order ordered by list of prefix_paths, compared as strings
dataset/ETHPy150Open ros-infrastructure/catkin_pkg/src/catkin_pkg/workspaces.py/order_paths