import sys from time import clock def main(): start = clock() fin=open("in10c_7.txt","r") fout=open("out_27_10c_7.txt","w") list=[] buckets = [[] for x in range(10)] #list of 10 empty buckets for x in fin: for y in x.split(','): list.append(int(y)) for item in list: buckets[item-1].append(item) i = 0 for bucket in buckets: for item in bucket: list[i] = item i += 1 l=[] for i in range(len(list)): l.append(str(list[i])) fout.write(",".join(l)) end = clock() time= end - start fout.write("\n\n Total execuion time ="+ str(time)+ " seconds") fout.write("\n Number of comparisons =" + str(0)) m=sys.getsizeof(list)+sys.getsizeof(x)+sys.getsizeof(y)+sys.getsizeof(l)+sys.getsizeof(buckets)+sys.getsizeof(item)+sys.getsizeof(fin)+sys.getsizeof(fout) fout.write("\n Memory used= "+str(m)+" bytes") fin.close() fout.close() main()