I can't figure out how to swap, so that amount and name will match after sort.
Here what I have:
Here what I have:
Code:
from numarray import *
import numarray.strings as str
n=input("Enter number of donors to be entered: ")
if n<5:
print "Please enter more then 5 donors."
n=input("Enter number of donors to be entered: ")
if n>=300:
print "Please enter less then 300 donors."
n=input("Enter number of donors to be entered: ")
donorsName=str.array(itemsize=20,shape=n)
amount=str.array(itemsize=20,shape=n)
for i in range(0,n):
print "Enter donors name:"
donorsName[i]=raw_input()
print "Enter amount donated $:"
amount[i]=raw_input()
print donorsName,amount
y=0
while y < n-1:
x=0
while x<n-1:
print amount
if amount[x+1]<amount[x]:
temp=amount[x+1]
pos=x
while amount[pos]>temp and pos>=0:
amount[pos+1]=amount[pos]
pos=pos-1
amount[pos+1]=temp
x=x+1
y=y+1
print" \nThe donor's name and amount donated:"
for i in range(0,n):
print donorsName[i],"$",amount[i]
print "\nProgram Completed......."
raw_input("Press enter to exit.")
Comment