sort_keys arg
See original GitHub issueA sort_keys
would be nice.
I know I can implement it myself with a few lines of code, but that doesn’t work from a logging config file.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5
Top Results From Across the Web
sortkeys | Looker
The sortkeys parameter lets you specify one or more columns of a persistent derived table (PDT) or an aggregate table on which to...
Read more >Module:Sortkey
This module sanitizes and escapes sortkeys so that they can be used inside the data-sort-value attribute of HTML tags in combination with table...
Read more >Sorting HOW TO — Python 3.11.1 documentation
Python lists have a built-in list.sort() method that modifies the list in-place. There is also a sorted() built-in function that builds a new...
Read more >jq Manual (development version)
Flush the output after each JSON object is printed (useful if you're piping a slow data source into jq and piping jq's output...
Read more >sortKey doesn't work on product connection in the ...
Describe the bug If I add sortKey as an arg to the products connection in the unoptimized sdk, either I get a PRICE...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’d like this feature as well and I’m kind of confused why this was closed.
@tuukkamustonen said that
OrderedDict
wouldn’t need to be used because passingsort_keys=True
tojson.dumps
handles the sorting.Then @offero said
and closed it. Which doesn’t really make sense to me. Maybe I’m misunderstanding something.
As far as I can tell the only way we can effectively call
json.dumps
withsort_keys=True
is to pass our ownjson_serializer
toJsonFormatter
.Some brief profiling:
Test data is from a JSON file containing 8000 randomly generated entries(generated using https://www.json-generator.com) into a dict.
I ran both
json.dumps(data)
andjson.dumps(data, sort_keys=True)
100 times.The former spent a total time of 14,554ms in
iterencode
while the ladder spent 16,580ms initerencode
.So on average not sorting took 145.54ms and sorting took 165.8ms resulting in a 20.26ms difference between the two.
These numbers are from Python 3.7 but Python 3.5 showed similar results.
I don’t understand. How do you recommend I use sort_keys from a logging config file? I don’t see any way to do that.