<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ls(checks):
 """List active or available environments."""

    if checks:
        checks = sorted(get_testable_checks() & set(checks))

        for check in checks:
            envs = get_available_tox_envs(check, e2e_only=True)

            if envs:
                echo_success('{}:'.format(check))
                for env in envs:
                    echo_info(env, indent=True)

    else:
        for check in get_configured_checks():
            envs = get_configured_envs(check)

            if envs:
                echo_success('{}:'.format(check))
                for env in envs:
                    echo_info(env, indent=True)