class Solution:
@staticmethod
def swap(n1: int, n2: int) -> bool:
return str(n1) + str(n2) < str(n2) + str(n1)
def solution(self, nums):
i = 1
while i < len(nums):
j = i
while j > 0 and self.swap(nums[j - 1], nums[j]):
nums[j - 1], nums[j] = nums[j], nums[j - 1]
j -= 1
# 1. μΌμͺ½μμλΆν° μΈλ±μ€ 1λΆν° μμν΄μ μ λ ¬ν΄λκ°
# 2. μΌμͺ½μ λ€ μ λ ¬ λμ΄μκΈ° λλ¬Έμ λμ λΉκ΅μ νλ²λ§μ λλ μλ μμ΄μ λ§μ½ μ λΆ μ λ ¬λμ΄μμΌλ©΄ O(n)λ κ°λ₯
i += 1
return str(int(''.join(map(str, nums))))
# 3. mapν¨μ μ¬μ©λ² μ°Έκ³
s = [3, 30, 34, 5, 9]
result = Solution().solution(s)
print(result)