String Comparison And Alphabetic Order of Individual Characters

后端 未结 4 1147
死守一世寂寞
死守一世寂寞 2021-02-18 23:06

I have a question related to string comparison vs. character comparison.

Characters > and 0 (zero) have following decimal values 62

4条回答
  •  庸人自扰
    2021-02-18 23:51

    it returns -1 because it is comparing str2 to str1, not the other way around. Eg, "is 48 equal to 62". No, it's less than 62 so it returns -1. It's semantically a little confusing when you read the parameter order

提交回复
热议问题