def resort_client_actions(portal):
    """Resorts client action views
    """
    sorted_actions = [
        "edit",
        "contacts",
        "view", # this redirects to analysisrequests
        "analysisrequests",
        "batches",
        "samplepoints",
        "profiles",
        "templates",
        "specs",
        "orders",
        "reports_listing"
    ]
    type_info = portal.portal_types.getTypeInfo("Client")
    actions = filter(lambda act: act.id in sorted_actions, type_info._actions)
    missing = filter(lambda act: act.id not in sorted_actions, type_info._actions)

    # Sort the actions
    actions = sorted(actions, key=lambda act: sorted_actions.index(act.id))
    if missing:
        # Move the actions not explicitily sorted to the end
        actions.extend(missing)

    # Reset the actions to type info
    type_info._actions = actions
Resorts client action views