Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Help with case insensitive sort

dragonflame17dragonflame17 Posts: 1Member
I have writen this code and everything runs, but I wanted to add case insensitivity to avoid the chance of the capitalized words being printed first. Does any one have any ideas on how to make that work, I have tried many different ways, but Im unsure how to work it with a list.

[code]
def main():
names = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0]
index = 0
while index < len(names):
names[index] = raw_input('Enter name number ' + str(index +1)+ ':')
index = index + 1
insertionSort(names)

def insertionSort(names):
index = 0
while index < len(names):
unsortedValue = names[index]
scan = index
while scan > 0 and names[scan - 1] > unsortedValue:
names[scan] = names[scan - 1]
scan = scan - 1
names[scan] = unsortedValue
index = index + 1
print names
main()
[/code]

Comments

Sign In or Register to comment.