Timeline for Number aware string sorting with comparator
Current License: CC BY-SA 3.0
3 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 12, 2013 at 14:25 | comment | added | rolfl | @pbible - when I wrote my answer I worked on the assumption (which is broken, I think) that if s1parts[x] is a number then s2parts[x] is also a number (and visa-versa for string). As a result I thought I only needed to check one side to see if it was numeric. Now I see that, if the input is: "file10x" and "10filex" you will still get an exception.... so, you are right, you should have the second check. | |
Dec 12, 2013 at 14:21 | comment | added | pbible | Good points. Static pattern and a check before the exception are both great points. I think that adding a check on s2parts[i] in your if statement would ensure the try never thorws the exception. If s1part[i] is numeric but s2part[i] is not a normal string compare would be fine. Thoughts? | |
Dec 12, 2013 at 12:38 | history | answered | rolfl | CC BY-SA 3.0 |