Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not possible to compare str and int when sorting #10

Open
BSVogler opened this issue Feb 1, 2022 · 0 comments
Open

Not possible to compare str and int when sorting #10

BSVogler opened this issue Feb 1, 2022 · 0 comments

Comments

@BSVogler
Copy link

BSVogler commented Feb 1, 2022

Great library. Thanks.

Problem:

Today I noticed that it crashed when you have a list of objects which is then sorted and the keys have different data types.

TypeError: '<' not supported between instances of 'str' and 'int'

in init.py in _sorter at line 205
with

obj=[[
0, {
code: 0, 
someothervalue: 'asd'
}],
[
1, {
code: 'N', 
someothervalue: 'dfdf'
}]]

and
sortby=code

Expected behaviour:

Since there is no rfc for JSON path, I am not sure what the conventional behaviour is then. I assume that sorting by casting all to string makes sense if one of them is a string. Other option would be to throw a custom error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant