(
    *args: Union[ElementType, ChoiceSweep, RangeSweep],
    sweep: Optional[Union[ChoiceSweep, RangeSweep]] = None,
    list: Optional[List[Any]] = None,
    reverse: bool = False,
)
Sort an input list or sweep.
    reverse=True reverses the order
Sort an input list or sweep.
    reverse=True reverses the order
Sort an input list or sweep . reverse = True reverses the order
def sort(
    *args: Union[ElementType, ChoiceSweep, RangeSweep],
    sweep: Optional[Union[ChoiceSweep, RangeSweep]] = None,
    list: Optional[List[Any]] = None,
    reverse: bool = False,
) -> Any:
    """
    Sort an input list or sweep.
    reverse=True reverses the order
    """

    if list is not None:
        return sort(list, reverse=reverse)
    if sweep is not None:
        return _sort_sweep(sweep, reverse)

    if len(args) == 1:
        arg = args[0]
        if isinstance(arg, (ChoiceSweep, RangeSweep)):
            # choice: sort(choice(a,b,c))
            # range: sort(range(1,10))
            return _sort_sweep(arg, reverse)
        elif isinstance(arg, builtins.list):
            return sorted(arg, reverse=reverse)
        elif is_type_matching(arg, ParsedElementType):
            return arg
        else:
            raise TypeError(f"Invalid arguments: {args}")
    else:
        primitives = (int, float, bool, str)
        for arg in args:
            if not isinstance(arg, primitives):
                raise TypeError(f"Invalid arguments: {args}")
        if len(args) == 0:
            raise ValueError("empty sort input")
        elif len(args) > 1:
            cw = _list_to_simple_choice(*args)
            return _sort_sweep(cw, reverse)
def sort ( * args : Union [ ElementType , ChoiceSweep , RangeSweep ] , sweep : Optional [ Union [ ChoiceSweep , RangeSweep ] ] = None , list : Optional [ List [ Any ] ] = None , reverse : bool = False , ) -> Any : if list is not None : return sort ( list , reverse = reverse ) if sweep is not None : return _sort_sweep ( sweep , reverse ) if len ( args ) == 1 : arg = args [ 0 ] if isinstance ( arg , ( ChoiceSweep , RangeSweep ) ) : # choice: sort(choice(a,b,c)) # range: sort(range(1,10)) return _sort_sweep ( arg , reverse ) elif isinstance ( arg , builtins . list ) : return sorted ( arg , reverse = reverse ) elif is_type_matching ( arg , ParsedElementType ) : return arg else : raise TypeError ( f"Invalid arguments: {args}" ) else : primitives = ( int , float , bool , str ) for arg in args : if not isinstance ( arg , primitives ) : raise TypeError ( f"Invalid arguments: {args}" ) if len ( args ) == 0 : raise ValueError ( "empty sort input" ) elif len ( args ) > 1 : cw = _list_to_simple_choice ( * args ) return _sort_sweep ( cw , reverse )