String Compare “Logic”

前端 未结 11 1605
悲哀的现实
悲哀的现实 2020-12-06 19:06

Can anybody please tell me why the string comparisons below deliver these results?

>>\"1040\"<=\"12000\"  
True  
>> \"1040\"<=\"1         


        
11条回答
  •  一生所求
    2020-12-06 19:49

    You're experiencing lexicographical ordering.

    There are some generalized algorithms for this ordering in the book Elements of Programming. Search for the word lexicographical.

提交回复
热议问题