Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. int compare(Node *a, Node *b){
  2.     int retVal = abs(b->f1_count - b->f2_count) - abs(a->f2_count - a->f1_count); //sort by how much they occur
  3.  
  4.     if(!retVal){                                        //if they occur the same (retVal would be 0) sort by name
  5.         retVal = strlen(b->name) - strlen(a->name);
  6.  
  7.         if(!retVal)                                     //if they are the same len (retVal would be 0) sort alphabetically
  8.         retVal = strcmp(a->name, b->name);
  9.     }
  10.     return retVal;
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement