sba/sorting.h
stmctommyau 771b36b4a6 admin ongoing;
inventory control basically finish;
debug needed
2022-09-06 23:25:14 +08:00

25 lines
588 B
C

typedef struct Map{
int key;
void* value;
}Map;
int compare_decending(const void *a, const void *b){
if((*(struct Map *)b).value == NULL){//for dont sort new item
return -1;
}else if((*(struct Map *)a).value == NULL){
return 1;
}
return (*(struct Map *)b).value - (*(struct Map *)a).value;
}
int compare_ascending(const void *a, const void *b){
if((*(struct Map *)b).value == NULL){
return -1;
}else if((*(struct Map *)a).value == NULL){
return 1;
}
return (*(struct Map *)a).value - (*(struct Map *)b).value;
}