Sort

Category:Algorithm
int main(int argc, char *argv[]) {
printf("Hello, world!"); /* Display a message */
exit(0);
}
int main(int argc, char *argv[]) {
printf("Hello, world!"); /* Display a message */
exit(0);
}
def insert_sort(seq):
	for j in rseqnge(1,len(seq)):
	 key=seq[j]
	 i=j-1
	 while i>=0 and seq[i]>key:
	 	seq[i+1]=seq[i]
		i=i-1
	 seq[i+1]=key
int main(int argc, char *argv[]) {
printf("Hello, world!"); /* Display a message */
exit(0);
}
def insert_sort(seq):
	for j in rseqnge(1,len(seq)):
	 key=seq[j]
	 i=j-1
	 while i>=0 and seq[i]>key:
	 	seq[i+1]=seq[i]
		i=i-1
	 seq[i+1]=key
		
def merge_sort(seq):
	if(len(seq) <= 1): return seq
	seql=merge_sort(seq[0:len(seq)/2])
	seqr=merge_sort(seq[len(seq)/2:len(seq)])
	for i in range(len(seq)):
		if len(seql) > 0 and len(seqr)> 0:
			if seql[0] > seqr[0]:
				seq[i]=seqr.pop(0)
			else:
				seq[i]=seql.pop(0)
		elif len(seql) > 0:
			seq[i]=seql.pop(0)
		else: seq[i]=seqr.pop(0)
	return seq
def quick_sort(seq):
 if not seq: return []
 return quick_sort([x for x in seq[1:] if x< seq[0]]) + seq[0:1] + \
 quick_sort([x for x in seq[1:] if x>=seq[0]])
def bubble_sort(seq):
	for i in range(len(seq)):
		for j in range(len(seq)-1,i,-1):
			if seq[j]<seq[j-1]:
				tmp=seq[j]
				seq[j]=seq[j-1]
				seq[j-1]=tmp
	return seq