Last active
January 26, 2018 07:58
-
-
Save lagenorhynque/399122d0ee2ae32f28a75d8fe5280666 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| user> (import '(java.util ArrayList Collections Comparator)) | |
| java.util.Comparator | |
| user> (def array-list (doto (ArrayList.) | |
| (.add 1) | |
| (.add 5) | |
| (.add 2))) | |
| #'user/array-list | |
| user> array-list | |
| [1 5 2] | |
| user> (Collections/sort array-list | |
| (reify Comparator | |
| (compare [_ x y] (- y x)))) | |
| nil | |
| user> array-list | |
| [5 2 1] | |
| user> (def array-list (doto (ArrayList.) | |
| (.add 1) | |
| (.add 5) | |
| (.add 2))) | |
| #'user/array-list | |
| user> (Collections/sort array-list | |
| #(compare %2 %1)) | |
| nil | |
| user> array-list | |
| [5 2 1] | |
| user> (def array-list (doto (ArrayList.) | |
| (.add 1) | |
| (.add 5) | |
| (.add 2))) | |
| #'user/array-list | |
| user> (Collections/sort array-list | |
| #(- %2 %1)) | |
| nil | |
| user> array-list | |
| [5 2 1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment