7 5 9 0 3 1 6 2 4 8
0 1 2 3 4 5 6 7 8 9
arr = list(map(int, input().split()))
for i in range(len(arr)):
min_idx = i
for j in range(i + 1, len(arr)):
if arr[j] < arr[min_idx]:
min_idx = j
arr[i], arr[min_idx] = arr[min_idx], arr[i]
for a in arr:
print(a, end=' ')
7 5 9 0 3 1 6 2 4 8
0 1 2 3 4 5 6 7 8 9
arr = list(map(int, input().split()))
for i in range(1, len(arr)):
for j in range(i, 0, -1):
if arr[j - 1] > arr[j]:
arr[j - 1], arr[j] = arr[j], arr[j - 1],
else:
break
for a in arr:
print(a, end=' ')
5, 7, 9, 0, 3, 1, 6, 2, 4, 8
0 1 2 3 4 5 6 7 8 9
def quick_sort(arr):
if len(arr) <= 1:
return arr
pivot = arr[0]
tail = arr[1:]
left_side = [x for x in tail if x <= pivot]
right_side = [x for x in tail if x > pivot]
return quick_sort(left_side) + [pivot] + quick_sort(right_side)
arr = list(map(int, input().split(',')))
res = quick_sort(arr)
for r in res:
print(r, end=' ')
7, 5, 9, 0, 3, 1, 6, 2, 9, 1, 4, 8, 0, 5, 2
0 0 1 1 2 2 3 4 5 5 6 7 8 9 9
arr = list(map(int, input().split(',')))
count = [0] * (max(arr) + 1)
for i in range(len(arr)):
count[arr[i]] += 1
res = []
for i in range(len(count)):
for j in range(count[i]):
res.append(i)
for r in res:
print(r, end=' ')
(오름차순 정렬 기준 설명)
5 3
1 2 5 4 3
5 5 6 6 5
26
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort(reverse=True)
for i in range(k):
if a[i] < b[i]:
a[i], b[i] = b[i], a[i]
else:
break
print(sum(a))