Created
March 30, 2014 07:52
-
-
Save ksomemo/9869192 to your computer and use it in GitHub Desktop.
選択ソート
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| def my_selection_sort(nums): | |
| l = len(nums) | |
| for i in range(l): | |
| min_idx = i | |
| for j in range(i, l): | |
| if (nums[min_idx] > nums[j]): | |
| min_idx = j | |
| nums[i], nums[min_idx] = nums[min_idx], nums[i] | |
| print nums | |
| return nums | |
| if __name__ == '__main__': | |
| nums = range(10) | |
| random.shuffle(nums) | |
| print nums | |
| print my_selection_sort(nums) |
Author
ksomemo
commented
Mar 30, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment