https://kotlinlang.org logo
#android
Title
# android
g

gildor

04/12/2018, 8:11 AM
not sure what is “.numeric”, probably some more sofisticated algorithm that supports such comaparsion out of the box The problem that you just cannot compare strings 9 and 11. Also, you cannot just convert string to int, because you must also sort by letter My solution is pretty simple, you just sort by int number, then by letter. You can move number split to comparator, cached value just more efficient (parse only once), but not necessary (updated sample)
s

sylcn

04/12/2018, 8:50 AM
But door number has many type like 9/A 9-A. your solution is only works with one should know every possibilities of doornumber types ?
g

gildor

04/12/2018, 9:04 AM
you need a way how to normilize this (remove everything except letters)
Fixed, to work with digit and letter separator
I mean there is no magic, swift does something similar under the hood, maybe more sophisticated to support different cases