Lets define that String is 'alphabetically growing' when:
- Every letter is alphabetically bigger then previous one.
- It doesn't matter if letter is uppercase or not.
These Strings are 'alphabetically growing':
- "abcde"
- "aBfJz"
And these are not:
- "abbcd"
- "abdDz"
- "zba"
Lets assume that we are checking Strings which contain only letters. Checking if String is 'growing' can be done in Scala with following code:
val str = "aBgjz"
val growing = str.map(_.toLower).toSet.toList.sortWith( _ < _ ).mkString.equals(str.map(_.toLower))
This code works good but only for English letters. For Strings with Polish letters the result is wrong. In Polish alphabet letters are in following order:
a, ą, b, c, ć, d, e ...
so for:
val str = "aąbćdgz"
the result should be 'true'. So the question is:
How to check in Scala if given String is 'alphabetically growing' for a given locale?
val str = "aąbćdgz"
val locale_id = "pl_PL"
....
val growing = ......