Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Sort.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
void isort(float d[], int size)
{
int i,k,l;
float temp;
for(k=1;k<size;k++){ // insert elements starting from 2nd
for(i=0;i<k && d[i]<=d[k];i++); // find where to insert - ith place
temp=d[k]; // copy kth element to temp
for(l=k;l>i;l--) d[l]=d[l-1]; // shift to make room to insert at ith
d[i]=temp; //insert kth element to ith place
}
}

void main(){
int i;
float data[]={9,8,7,6,5,4,-13,2,1,0,1,2,3};
isort(data,13);
printf("\n");
for(i=0;i<13;i++) printf("%f\t",data[i]);
}