Advertisement
pierrotdu18

Untitled

Aug 20th, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. global MAX = 1, MIN = -1;
  2. function sortBy(array, func, type)
  3. {
  4.     var results = [];
  5.     for (var key : var element in array)
  6.     {
  7.         results[key] = func(element);
  8.     }
  9.     return type == MAX ? array[search(results, arrayMax(results))] : array[search(results, arrayMin(results))];
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement