Skip to content

Instantly share code, notes, and snippets.

@kraftpunk97
Last active March 29, 2023 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kraftpunk97/7d8a19c81d43fedf1fe3c5c7b4534873 to your computer and use it in GitHub Desktop.
Save kraftpunk97/7d8a19c81d43fedf1fe3c5c7b4534873 to your computer and use it in GitHub Desktop.
def func(list1, list2):
list1_ = [item for item in list1]
list2_ = [item for item in list2]
for ind in range(len(list1_)):
min_index = ind
for j in range(ind + 1, len(list1_)):
# select the minimum element in every iteration
if list2_[j] < list2_[min_index]:
min_index = j
# swapping the elements to sort the array
(list1_[ind], list1_[min_index]) = (list1_[min_index], list1_[ind])
(list2_[ind], list2_[min_index]) = (list2_[min_index], list2_[ind])
return list1_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment