Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int[] SelectionSort(int[] nums)
- {
- int endOfArray = nums.Length - 1;
- int smallestNbr;
- int nextNbr;
- for (int currentIndex = 0; currentIndex < endOfArray; currentIndex++)
- {
- smallestNbr = nums[currentIndex];
- for (int searchIndex = currentIndex + 1; searchIndex < endOfArray; searchIndex++)
- {
- nextNbr = nums[searchIndex];
- if(nextNbr < smallestNbr)
- {
- swap(nums, nums[currentIndex], nums[searchIndex]);
- }
- }
- }
- return nums;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement