def METHOD_NAME(selected_person: Person) -> List[List[Membership]]:
    """Orders memberships so that the active ones are first, those with unknown end seconds and the ended last."""
    memberships_active = (
        selected_person.membership_set.filter(end__gte=timezone.now().date())
        .prefetch_related("organization")
        .all()
    )
    memberships_no_end = (
        selected_person.membership_set.filter(end__isnull=True)
        .prefetch_related("organization")
        .all()
    )
    memberships_ended = (
        selected_person.membership_set.filter(end__lt=timezone.now().date())
        .prefetch_related("organization")
        .all()
    )
    memberships = []
    if len(memberships_active) > 0:
        memberships.append(memberships_active)
    if len(memberships_no_end) > 0:
        memberships.append(memberships_no_end)
    if len(memberships_ended) > 0:
        memberships.append(memberships_ended)
    return memberships