Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6993839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:48:55+00:00 2026-05-27T19:48:55+00:00

If this is the best (or a good) solution, can someone please explain exactly

  • 0

If this is the best (or a good) solution, can someone please explain exactly what it’s doing?

(sort
  (reduce (fn [x [y z]] (assoc x y z)) {} (System/getProperties)))

Where it can be used, for example to print the System properties:

(def p
  (sort
    (reduce (fn [x [y z]] (assoc x y z)) {} (System/getProperties))))

(defn pnv [nv] (println (str (key nv) "=\"" (val nv) "\"")))

(doseq [nv p] (pnv nv))

If that isn’t a good approach, please provide a better one. Thanks

I know that i can do:

(doseq [nv (System/getProperties)] (pnv nv))

But sorting doesn’t seem to work:

(doseq [nv (sort (System/getProperties))] (pnv nv))
ClassCastException java.util.Hashtable$Entry cannot be cast to java.lang.Comparable  clojure.lang.Util.compare (Util.java:104)

Solution, as provided by amalloy:

(doseq [nv (into (sorted-map) (System/getProperties))] (pnv nv))
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:48:56+00:00Added an answer on May 27, 2026 at 7:48 pm

    Maps are in general not sorted – certainly any map you get to by adding entries to {} won’t be. However, both Clojure and Java provide sorted maps. So if you want a sorted map with the default sort order, you can just do (into (sorted-map) the-other-map). This works for java.util.Map as well as for Clojure types, so it should be all you need.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to explain this as best as I can. I have a Webgrid
I'm pretty strong with SQL, but I can't think of good solution to this
Is this the best way to convert String hex to bytes? Or can you
This is the best way I can think of phrasing this question, given this
I know this isn't best practice, but can I include all of the dependencies
Is this the best way to handle file moving in a windows service? we
After reading this answer: best way to pick a random subset from a collection?
My question is that is this the best practice to do this. Couldn't find
I am not sure if I am going about this the best way, but
MessageBox.Show((some_string.Length).ToString); I am getting two errors for this: The best overloaded method match for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.