Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

34 lines (22 sloc) 0.481 kB
# Implementation of insertion sort in python
# Ditesh Shashikant Gathani 2010
import support
def sort(data):
j=1
outsideLoopCount=0
swapCount=0
length = len(data)
while j <= length -1:
k = 0
outsideLoopCount += 1
while k < j:
if data[k] > data[j]:
data = support.swap(data, k, j)
swapCount += 1
k += 1
j += 1
# print "Outside loop count: ", outsideLoopCount
# print "Swap count: ", swapCount
return data
def getName():
return "insertion"
Jump to Line
Something went wrong with that request. Please try again.