Advertisement
vaibhav1906

Sorting Employees

Nov 18th, 2021
1,372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. // bool compare(node a, node b){
  2.    
  3. //     if(a.salary < b.salary){
  4. //         return true;
  5. //     }
  6.    
  7. //     if(a.salary ==b.salary){
  8. //         return a.name <b.name;
  9. //     }
  10.    
  11. //     return false;
  12.    
  13. // }
  14.  
  15. class Solution{
  16.  
  17.     public:
  18.     void sortRecords(node arr[], int n)
  19.     {
  20.         // Your code goes here
  21.        
  22.        
  23.        
  24.         sort(arr,arr+n,[](node a, node b){
  25.             if(a.salary < b.salary){
  26.                 return true;
  27.             }
  28.    
  29.             if(a.salary ==b.salary){
  30.                 return a.name <b.name;
  31.             }
  32.    
  33.             return false;
  34.         });
  35.        
  36.     }
  37.      
  38.  
  39. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement