typedef struct Map{ int key; void* value; }Map; int compare_decending_str(const void *a, const void *b){ if((*(struct Map *)b).value == NULL){//To prevent null pointer cause error return -1; }else if((*(struct Map *)a).value == NULL){ return 1; } return strcmp((*(struct Map *)b).value,(*(struct Map *)a).value); } int compare_ascending_str(const void *a, const void *b){ if((*(struct Map *)b).value == NULL){ return -1; }else if((*(struct Map *)a).value == NULL){ return 1; } return strcmp((*(struct Map *)a).value,(*(struct Map *)b).value); } int compare_decending(const void *a, const void *b){ if((*(struct Map *)b).value == NULL){//To prevent null pointer cause error 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; }