|
|
|
|
|
by cmccabe
4720 days ago
|
|
Let me guess. You are coming from Java. In Java this would be: myArray.sort(new Comparator<MyClass> ({
@Override
CompareTo(MyClass lhs, MyClass rhs) {
return rhs.compare(lhs);
}
}));
Is that really shorter? I don't think so.In any case, there is a more elegant solution in Go, which is simply: sort.Sort(sort.Reverse(array))
You need to open your mind a little bit, to learn a new language. |
|
Nope. Clojure and Haskell. Clojure:
Haskell: