Guest User

Untitled

a guest
Nov 1st, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Vala 0.68 KB | None | 0 0
  1.         private int sort_apps (App a, App b) {
  2.  
  3.             if (a.popularity > b.popularity)
  4.                 return 1;
  5.             else if (a.popularity == b.popularity)
  6.                 return 0;
  7.             else
  8.                 return -1;
  9.  
  10.         }
  11.  
  12.         public SList<App> get_sorted_apps () {
  13.  
  14.             var sorted_apps = new SList<App> ();
  15.  
  16.             foreach (ArrayList<App> category in apps.values) {
  17.                 foreach (App app in category) {
  18.  
  19.                     sorted_apps.append (app);
  20.  
  21.                 }
  22.             }
  23.            
  24.             sorted_apps.sort_with_data ((CompareDataFunc<App>) sort_apps);
  25.             return sorted_apps;
  26.  
  27.         }
Add Comment
Please, Sign In to add comment