Created
          December 1, 2014 07:22 
        
      - 
      
- 
        Save dhiraka/251c55ce45ffc8fac410 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
    
  
  
    
  | def insertionSort(array) | |
| (1..array.length-1).each do |i| | |
| temp=array[i] | |
| j=i-1 | |
| while(j>=0 && array[j]>temp) | |
| array[j+1]=array[j] | |
| j -= 1 | |
| end | |
| array[j+1]=temp | |
| end | |
| return array | |
| end | |
| x=[5,3,8,1,7,9] | |
| puts insertionSort(x) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment