Sort array by string size, avoid substring replacements