Using sort_keys with python3's json.dumps Does Not Go Natural

Asked 2 years ago, Updated 2 years ago, 131 views

If you create a function in the following form and produce the results, 1,11,99,100 will not be in natural order in the following form.

 1,100, 11,99

Is there any way, please let me know.

def score_summary(rows):

    return json.dumps({
        'time': by_time(rows),
        'userno': by_userno(rows)

    }, sort_keys = True, indent = 4)

python python3 json

2022-09-30 21:48

1 Answers

Are each element to be sorted "string"?
If you change each element to int type, it will work.


2022-09-30 21:48

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.