qsort..
weight가 double이라면..
int compareDouble(const void *arg1, const void *arg2)
{
return (weightDoc*)arg2)->weight - ((weightDoc*)arg1)->weight;
}
거기다 대부분 값들이 소수점 이하라면..
정렬이 될리가 없지 않은가..
int compareDouble(const void *arg1, const void *arg2)
{
if( ((weightDoc*)arg1)->weight < ((weightDoc*)arg2)->weight )
return 1;
else if( ((weightDoc*)arg1)->weight > ((weightDoc*)arg2)->weight )
return -1;
else
return 0;
}
뻘짓 하지 맙시다..
weight가 double이라면..
int compareDouble(const void *arg1, const void *arg2)
{
return (weightDoc*)arg2)->weight - ((weightDoc*)arg1)->weight;
}
거기다 대부분 값들이 소수점 이하라면..
정렬이 될리가 없지 않은가..
int compareDouble(const void *arg1, const void *arg2)
{
if( ((weightDoc*)arg1)->weight < ((weightDoc*)arg2)->weight )
return 1;
else if( ((weightDoc*)arg1)->weight > ((weightDoc*)arg2)->weight )
return -1;
else
return 0;
}
뻘짓 하지 맙시다..