diff --git a/du6/program.c b/du6/program.c index baca34b..4643a31 100644 --- a/du6/program.c +++ b/du6/program.c @@ -66,12 +66,20 @@ void sort(struct LIS* list,int count){ char *min; int mini; for(int i=0;i<=count-1;i++){ - if(strcmp(list[i].fname,list[i+1].fname)==0 && strcmp(list[i].name,list[i+1].name)>0){ - ilusion=list[i]; - list[i]=list[i+1]; - list[i+1]=ilusion; - i++; + min=list[i].name; + mini=i; + for(int j=i+1;j<=count;j++){ + if(strcmp(min,list[j].name)>0){ + min=list[j].name; + mini=j; + } } + ilusion=list[i]; + list[i]=list[mini]; + list[mini]=ilusion; + } + //// + for(int i=0;i<=count-1;i++){ min=list[i].fname; mini=i; for(int j=i+1;j<=count;j++){