You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am making the proposal to change the default sorting algorithm for natsorted starting with version 4.0.0. Currently, natsorted looks for any string of numbers that are valid input to the float function in a greedy way (for example, "number-1.402e10hello" would be split into ['number', -14020000000.0, 'hello']).
My proposal would be to make the behavior of the current function versorted be the default behavior for natsorted, and make the current natsorted behavior belong to a new function (possibly called realnatsorted but I am open to suggestions). versorted would remain for backwards compatibility. A SIGNED attribute to the ns algorithm chooser class would have to be added. This would mean that natsorted would by default return results where "version2.2" < "version2.10" and "version-1.0" < "version-2.0" which I believe would meet most user's expectations.
I am polling the community to find out if I am correct in my assumption that people would expect natsorted to only look for digits and not '-' and '.' from a string, and if it would be worth it to modify the natsorted default behavior to provide less astonishment without breaking existing code too severely.
The text was updated successfully, but these errors were encountered:
SethMMorton
changed the title
Make sorting by unsigned integers the default?
Make sorting by unsigned integers the natsorted default?
Feb 7, 2015
SethMMorton
changed the title
Make sorting by unsigned integers the natsorted default?
Make sorting by unsigned integers the natsorted default?
Feb 7, 2015
I am making the proposal to change the default sorting algorithm for
natsorted
starting with version 4.0.0. Currently,natsorted
looks for any string of numbers that are valid input to thefloat
function in a greedy way (for example,"number-1.402e10hello"
would be split into['number', -14020000000.0, 'hello']
).I have observed that this does not pass the "rule of least astonishment" for most users because it is easy to not recognize that
'-'
and'.'
are actually valid parts of a number or that the algorithm would be accounting for signs and decimals, and thus users are surprised to seenatsorted
return results where"version2.10" < "version2.2"
or"version-2.0" < "version-1.0"
. I have observed this in this Stack Overflow Question, this issue reported to natsort, and this python module that was created becausenatsorted
did not meet their expectations and instead of filing a bug report attacked natsort in its documentation (the documentation was toned down in the 3rd commit).My proposal would be to make the behavior of the current function
versorted
be the default behavior fornatsorted
, and make the currentnatsorted
behavior belong to a new function (possibly calledrealnatsorted
but I am open to suggestions).versorted
would remain for backwards compatibility. ASIGNED
attribute to thens
algorithm chooser class would have to be added. This would mean thatnatsorted
would by default return results where"version2.2" < "version2.10"
and"version-1.0" < "version-2.0"
which I believe would meet most user's expectations.I am polling the community to find out if I am correct in my assumption that people would expect
natsorted
to only look for digits and not'-'
and'.'
from a string, and if it would be worth it to modify thenatsorted
default behavior to provide less astonishment without breaking existing code too severely.The text was updated successfully, but these errors were encountered: