async def METHOD_NAME(
    decoy: Decoy,
    usb_bus: USBDriverInterface,
    build_module: Callable[..., Awaitable[AbstractModule]],
    hardware_api: HardwareAPI,
    subject: AttachedModulesControl,
) -> None:
    """It should sort modules by port and hub, in ascending order."""
    module_1 = decoy.mock(cls=AbstractModule)
    decoy.when(module_1.usb_port).then_return(
        USBPort(name="a", port_number=4, hub=True, hub_port=2)
    )
    module_2 = decoy.mock(cls=AbstractModule)
    decoy.when(module_2.usb_port).then_return(
        USBPort(name="b", port_number=4, hub=True, hub_port=1)
    )
    module_3 = decoy.mock(cls=AbstractModule)
    decoy.when(module_3.usb_port).then_return(USBPort(name="c", port_number=3))
    module_4 = decoy.mock(cls=AbstractModule)
    decoy.when(module_4.usb_port).then_return(USBPort(name="x", port_number=2))
    new_mods_at_ports = [ModuleAtPort(port="/dev/foo", name="bar")]
    actual_ports = [
        ModuleAtPort(port="/dev/a", name="magdeck", usb_port=module_1.usb_port),
        ModuleAtPort(port="/dev/b", name="tempdeck", usb_port=module_2.usb_port),
        ModuleAtPort(port="/dev/c", name="thermocycler", usb_port=module_3.usb_port),
        ModuleAtPort(port="/dev/d", name="heatershaker", usb_port=module_4.usb_port),
    ]
    decoy.when(usb_bus.match_virtual_ports(new_mods_at_ports)).then_return(actual_ports)
    for mod in [module_1, module_2, module_3, module_4]:
        decoy.when(
            await build_module(
                usb_port=mod.usb_port,
                port=matchers.Anything(),
                type=matchers.Anything(),
            )
        ).then_return(mod)
    await subject.register_modules(new_mods_at_ports=new_mods_at_ports)
    result = subject.available_modules
    assert result == [module_4, module_3, module_2, module_1]