/sorted-map-by.clj Secret
Created
March 8, 2012 17:57
-
-
Save llasram/ee28d4333002d516dffd to your computer and use it in GitHub Desktop.
This file contains 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
(let [result {:AR 6, :AU 2, :BG 1, :BN 1, :BO 2, :BR 8, :CA 5, :CH 1, :CL 18, | |
:CN 4, :CO 9, :CR 3, :CU 1, :CV 1, :CZ 1, :DE 14, :EC 3, :EE 1, | |
:ES 8, :FR 8, :GB 14, :GE 1, :GR 1, :GT 15, :HK 5, :HN 1, :HT 1, | |
:ID 89, :IE 1, :IN 5, :IQ 2, :IT 5, :JP 14, :KE 1, :KR 3, :KW 4, | |
:LR 1, :MT 1, :MX 81, :MY 6, :NG 2, :NL 10, :NO 1, :PA 1, :PE 11, | |
:PH 2, :RO 47, :RU 1, :SE 3, :SG 7, :SV 3, :TR 5, :TZ 5, :US 332, | |
:UZ 1, :VE 3, :ZA 2}] | |
(into (sorted-map-by (fn [key1 key2] | |
(compare [(get result key1) key1] | |
[(get result key2) key2]))) | |
result)) | |
=> {:BG 1, :BN 1, :CH 1, :CU 1, :CV 1, :CZ 1, :EE 1, :GE 1, :GR 1, :HN 1, :HT 1, :IE 1, :KE 1, :LR 1, :MT 1, :NO 1, :PA 1, :RU 1, :UZ 1, :AU 2, :BO 2, :IQ 2, :NG 2, :PH 2, :ZA 2, :CR 3, :EC 3, :KR 3, :SE 3, :SV 3, :VE 3, :CN 4, :KW 4, :CA 5, :HK 5, :IN 5, :IT 5, :TR 5, :TZ 5, :AR 6, :MY 6, :SG 7, :BR 8, :ES 8, :FR 8, :CO 9, :NL 10, :PE 11, :DE 14, :GB 14, :JP 14, :GT 15, :CL 18, :RO 47, :MX 81, :ID 89, :US 332} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment