



'''simple docstring'''

def a_     (    __UpperCAmelCase					)				->					list[list[float]]:





			"""simple docstring"""







			snake_case:    list[list[float]]      							=[]
			for data in source_data:
						for i, el in enumerate(__UpperCAmelCase					):
									if len(__UpperCAmelCase					) < i + 1:
												data_lists.append([]					)
									data_lists[i].append(float(__UpperCAmelCase					)					)
			return data_lists







def a_     (    __UpperCAmelCase				,							__UpperCAmelCase					)				->					list[list[float]]:





			"""simple docstring"""







			snake_case:    list[list[float]]      							=[]
			for dlist, weight in zip(__UpperCAmelCase				,							__UpperCAmelCase					):
						snake_case:    List[Any]      							=min(__UpperCAmelCase					)
						snake_case:    List[str]      							=max(__UpperCAmelCase					)

						snake_case:    list[float]      							=[]
						# for weight 0 score is 1 - actual score
						if weight == 0:
									for item in dlist:
												try:
															score.append(1 - ((item - mind) / (maxd - mind))					)
												except ZeroDivisionError:
															score.append(1					)

						elif weight == 1:
									for item in dlist:
												try:
															score.append((item - mind) / (maxd - mind)					)
												except ZeroDivisionError:
															score.append(0					)

        # weight not 0 or 1
						else:
									snake_case:    Dict      							=f'''Invalid weight of {weight:f} provided'''
									raise ValueError(__UpperCAmelCase					)

						score_lists.append(__UpperCAmelCase					)

			return score_lists







def a_     (    __UpperCAmelCase					)				->					list[float]:





			"""simple docstring"""







			snake_case:    list[float]      							=[0 for i in range(len(score_lists[0]					)					)]

			for slist in score_lists:
						for j, ele in enumerate(__UpperCAmelCase					):
									snake_case:    List[Any]      							=final_scores[j] + ele

			return final_scores







def a_     (    __UpperCAmelCase				,							__UpperCAmelCase					)				->					list[list[float]]:





			"""simple docstring"""







			snake_case:    str      							=get_data(__UpperCAmelCase					)
			snake_case:    Union[str, Any]      							=calculate_each_score(__UpperCAmelCase				,							__UpperCAmelCase					)
			snake_case:    str      							=generate_final_scores(__UpperCAmelCase					)

			# append scores to source data
			for i, ele in enumerate(__UpperCAmelCase					):
						source_data[i].append(__UpperCAmelCase					)

			return source_data









'''simple docstring'''

from __future__ import annotations

from bisect import bisect_left
from functools import total_ordering
from heapq import merge






@total_ordering
class 						a_		(     snake_case    ):


							def __lt__(				self   :						List[Any]      ,						a_   :						Optional[int]			)			->					List[str]:
										return self[-1] < other[-1]




							def __eq__(				self   :						int      ,						a_   :						Union[str, Any]			)			->					List[str]:
										return self[-1] == other[-1]







def a_     (    __UpperCAmelCase					)				->					list:





			"""simple docstring"""







			snake_case:    list[Stack]      							=[]
			# sort into stacks
			for element in collection:
						snake_case:    int      							=Stack([element]					)
						snake_case:    Union[str, Any]      							=bisect_left(__UpperCAmelCase				,							__UpperCAmelCase					)
						if i != len(__UpperCAmelCase					):
									stacks[i].append(__UpperCAmelCase					)
						else:
									stacks.append(__UpperCAmelCase					)

    # use a heap-based merge to merge stack efficiently
			snake_case:    int      							=merge(*(reversed(__UpperCAmelCase					) for stack in stacks)					)
			return collection


if __name__ == "__main__":
	a							   =				input('Enter numbers separated by a comma:\n').strip()
	a							   =				[int(item) for item in user_input.split(',')]
	print(patience_sort(unsorted))




