



"""simple docstring"""


from ..utils import DummyObject, requires_backends
class 			_a (					metaclass=lowerCAmelCase):
			"""simple docstring"""
			UpperCamelCase__			      =	["""torch""", """transformers""", """onnx"""]



			def __init__(		self     :    int				,   *__UpperCamelCase     :    Dict				,   **__UpperCamelCase     :    Tuple   )->str:
							requires_backends(self				,   ['''torch''', '''transformers''', '''onnx''']   )



			@classmethod
			def  lowercase__						(		cls     :    Any				,   *__UpperCamelCase     :    str				,   **__UpperCamelCase     :    List[str]   )->Any:
							requires_backends(cls				,   ['''torch''', '''transformers''', '''onnx''']   )



			@classmethod
			def  lowercase__						(		cls     :    str				,   *__UpperCamelCase     :    Union[str, Any]				,   **__UpperCamelCase     :    Optional[int]   )->List[str]:
							requires_backends(cls				,   ['''torch''', '''transformers''', '''onnx''']   )



class 			_a (					metaclass=lowerCAmelCase):
			"""simple docstring"""
			UpperCamelCase__			      =	["""torch""", """transformers""", """onnx"""]



			def __init__(		self     :    List[Any]				,   *__UpperCamelCase     :    Tuple				,   **__UpperCamelCase     :    List[Any]   )->int:
							requires_backends(self				,   ['''torch''', '''transformers''', '''onnx''']   )



			@classmethod
			def  lowercase__						(		cls     :    Dict				,   *__UpperCamelCase     :    List[Any]				,   **__UpperCamelCase     :    Tuple   )->Any:
							requires_backends(cls				,   ['''torch''', '''transformers''', '''onnx''']   )



			@classmethod
			def  lowercase__						(		cls     :    str				,   *__UpperCamelCase     :    Tuple				,   **__UpperCamelCase     :    Tuple   )->int:
							requires_backends(cls				,   ['''torch''', '''transformers''', '''onnx''']   )



class 			_a (					metaclass=lowerCAmelCase):
			"""simple docstring"""
			UpperCamelCase__			      =	["""torch""", """transformers""", """onnx"""]



			def __init__(		self     :    Tuple				,   *__UpperCamelCase     :    Optional[Any]				,   **__UpperCamelCase     :    int   )->List[str]:
							requires_backends(self				,   ['''torch''', '''transformers''', '''onnx''']   )



			@classmethod
			def  lowercase__						(		cls     :    Any				,   *__UpperCamelCase     :    Dict				,   **__UpperCamelCase     :    Dict   )->List[str]:
							requires_backends(cls				,   ['''torch''', '''transformers''', '''onnx''']   )



			@classmethod
			def  lowercase__						(		cls     :    int				,   *__UpperCamelCase     :    Dict				,   **__UpperCamelCase     :    Optional[Any]   )->List[Any]:
							requires_backends(cls				,   ['''torch''', '''transformers''', '''onnx''']   )



class 			_a (					metaclass=lowerCAmelCase):
			"""simple docstring"""
			UpperCamelCase__			      =	["""torch""", """transformers""", """onnx"""]



			def __init__(		self     :    Union[str, Any]				,   *__UpperCamelCase     :    List[str]				,   **__UpperCamelCase     :    str   )->List[Any]:
							requires_backends(self				,   ['''torch''', '''transformers''', '''onnx''']   )



			@classmethod
			def  lowercase__						(		cls     :    Tuple				,   *__UpperCamelCase     :    str				,   **__UpperCamelCase     :    int   )->Dict:
							requires_backends(cls				,   ['''torch''', '''transformers''', '''onnx''']   )



			@classmethod
			def  lowercase__						(		cls     :    Any				,   *__UpperCamelCase     :    List[Any]				,   **__UpperCamelCase     :    List[Any]   )->Optional[Any]:
							requires_backends(cls				,   ['''torch''', '''transformers''', '''onnx''']   )



class 			_a (					metaclass=lowerCAmelCase):
			"""simple docstring"""
			UpperCamelCase__			      =	["""torch""", """transformers""", """onnx"""]



			def __init__(		self     :    Any				,   *__UpperCamelCase     :    Union[str, Any]				,   **__UpperCamelCase     :    Optional[Any]   )->Dict:
							requires_backends(self				,   ['''torch''', '''transformers''', '''onnx''']   )



			@classmethod
			def  lowercase__						(		cls     :    Dict				,   *__UpperCamelCase     :    Optional[Any]				,   **__UpperCamelCase     :    Optional[Any]   )->Union[str, Any]:
							requires_backends(cls				,   ['''torch''', '''transformers''', '''onnx''']   )



			@classmethod
			def  lowercase__						(		cls     :    str				,   *__UpperCamelCase     :    Tuple				,   **__UpperCamelCase     :    Union[str, Any]   )->Optional[int]:
							requires_backends(cls				,   ['''torch''', '''transformers''', '''onnx''']   )



class 			_a (					metaclass=lowerCAmelCase):
			"""simple docstring"""
			UpperCamelCase__			      =	["""torch""", """transformers""", """onnx"""]



			def __init__(		self     :    Optional[Any]				,   *__UpperCamelCase     :    Union[str, Any]				,   **__UpperCamelCase     :    int   )->str:
							requires_backends(self				,   ['''torch''', '''transformers''', '''onnx''']   )



			@classmethod
			def  lowercase__						(		cls     :    Tuple				,   *__UpperCamelCase     :    Union[str, Any]				,   **__UpperCamelCase     :    Any   )->List[Any]:
							requires_backends(cls				,   ['''torch''', '''transformers''', '''onnx''']   )



			@classmethod
			def  lowercase__						(		cls     :    Dict				,   *__UpperCamelCase     :    List[Any]				,   **__UpperCamelCase     :    List[str]   )->List[Any]:
							requires_backends(cls				,   ['''torch''', '''transformers''', '''onnx''']   )








"""simple docstring"""


import operator







def  lowercase	(      _SCREAMING_SNAKE_CASE   :						list					,     _SCREAMING_SNAKE_CASE   :						bool = False					,     _SCREAMING_SNAKE_CASE   :						list | None = None				):






				'''simple docstring'''



				_UpperCAmelCase					=    operator.lt if reverse else operator.gt
				_UpperCAmelCase					=    solution or []

				if not arr:
								return solution

				_UpperCAmelCase					=    [arr.pop(0				)]
				for i, item in enumerate(_SCREAMING_SNAKE_CASE				):
								if _operator(_SCREAMING_SNAKE_CASE					,     sublist[-1]				):
												sublist.append(_SCREAMING_SNAKE_CASE				)
												arr.pop(_SCREAMING_SNAKE_CASE				)

    #  merging sublist into solution list
				if not solution:
								solution.extend(_SCREAMING_SNAKE_CASE				)
				else:
								while sublist:
												_UpperCAmelCase					=    sublist.pop(0				)
												for i, xx in enumerate(_SCREAMING_SNAKE_CASE				):
																if not _operator(_SCREAMING_SNAKE_CASE					,     _SCREAMING_SNAKE_CASE				):
																				solution.insert(_SCREAMING_SNAKE_CASE					,     _SCREAMING_SNAKE_CASE				)
																				break
												else:
																solution.append(_SCREAMING_SNAKE_CASE				)

				strand_sort(_SCREAMING_SNAKE_CASE					,     _SCREAMING_SNAKE_CASE					,     _SCREAMING_SNAKE_CASE				)
				return solution


if __name__ == "__main__":
					assert strand_sort([4, 3, 5, 1, 2]) == [1, 2, 3, 4, 5]
					assert strand_sort([4, 3, 5, 1, 2], reverse=True) == [5, 4, 3, 2, 1]



