Given a string of words separated by spaces. You have to transform this string into a data structure that groups these words by their first letters.
The groups should be sorted in alphabetical order. Inner words should be sorted by their lengths and also in alphabetical order if the lengths are equal.
before = "сапог сарай арбуз болт бокс биржа"
// transform
. . .
after = "[б=[биржа, бокс, болт], c=[caпог, сарай]]"