The common way, written in Scala:
scala> def isAnagram(s1: String, s2: String): Boolean = s1.sorted.equalsIgnoreCase(s2.sorted)
isAnagram: (s1: String, s2: String)Boolean
scala> isAnagram("stressed", "desserts")
res1: Boolean = true
scala> isAnagram("sad", "happy")
res2: Boolean = false
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.