We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
if a(type string) has more characters than b(also type string). Then a is the larger number since there are no leading zeros.
For example if
vara="15548459";varb="5478";
then you don't even have to read the string(i.e. do a string comparison). You can strongly say that a is greater than b.
Comparison is similar to IComparer's method called Compare(Object,Object). If the return is positive, then a is greater than b. a.Length-b.Length just means return positive if a is greater, negative if less. (They are never equal in my case since the logic operator beforehand addresses this.)
Big Sorting
You are viewing a single comment's thread. Return to all comments →
if a(type string) has more characters than b(also type string). Then a is the larger number since there are no leading zeros.
For example if
then you don't even have to read the string(i.e. do a string comparison). You can strongly say that a is greater than b.
Comparison is similar to IComparer's method called Compare(Object,Object). If the return is positive, then a is greater than b. a.Length-b.Length just means return positive if a is greater, negative if less. (They are never equal in my case since the logic operator beforehand addresses this.)