It is true that it would find them in any order, but that if there were duplicates, it would generate an error. I wasn't sure if there might be some circumstance where '3s2m' might be valid input. Hey, you never know!
You need the correct order for the encoding only, yes, not the decoding. The only reason I made that function was for the sake of completeness, and to validate that my decodes were correct using the test harness.
A definition of
idempotent for the curious.