wolever / pprintpp

pprint++: a drop-in replacement for pprint that's actually pretty
Other
408 stars 21 forks source link

add sort_dicts option #27

Open gergelyk opened 4 years ago

gergelyk commented 4 years ago

As regular dicts have guaranteed order from Python 3.7, it makes sense to add sort_dicts option as in case of pprint from the standard library.

wolever commented 4 years ago

Hey! Thanks for the PR!

Two things:

  1. The default should be False on Py3 (as dicts are already ordered) and the documentation should reflect this
  2. Please add tests, including one which confirms that it will only sort dicts, not dict-like things like OrderedDict which already have an order.
gergelyk commented 4 years ago

Hi. Thanks a million for your quick reply. Unfortunately I'm currently overloaded and may not be able to deliver this change. Let's forget about it. Sorry for bothering.

joaonc commented 4 years ago

Re 1. above, I actually think it should default to True (as is now) because that's the default value in Python 3.8 and if this package is to be a drop replacement o pprint, then keeping the default values should be observed.

peter-malcolm-bw commented 2 years ago

Came here looking for this functionality and found this issue. Is this still something that you would be interested in merging (if relevant tests were added?)

Sil3ntStorm commented 2 years ago

Appears t work fine, would love to this this actually be in. Too bad there hasn't been any activity on this.

Kache commented 2 years ago

IMO ideally sort_dicts would differ based on contextual use-case: