Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global MAX = 1, MIN = -1;
- function sortBy(array, func, type)
- {
- var results = [];
- for (var key : var element in array)
- {
- results[key] = func(element);
- }
- return type == MAX ? array[search(results, arrayMax(results))] : array[search(results, arrayMin(results))];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement