Advertisement
Guest User

Untitled

a guest
Sep 8th, 2013
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.31 KB | None | 0 0
  1. auto sortBy(alias get, alias predicate = less, Range)(Range range) {
  2.     static if (is(typeof(get) == string)) {
  3.         static auto getFunc(T)(T _) {
  4.             return mixin(get);
  5.         }
  6.     } else {
  7.         alias get getFunc;
  8.     }
  9.  
  10.     return range.sort!((x, y) => (predicate(getFunc(x), getFunc(y))));
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement