String Sorting Concatenation Function

  • Share this:

Code introduction


The function takes two string arguments, concatenates them, sorts the characters in the concatenated string, and returns the result.


Technology Stack : String (str), sorting (sorted)

Code Type : String Handling Function

Code Difficulty : Intermediate


                
                    
def azip(arg1, arg2):
    if not isinstance(arg1, str) or not isinstance(arg2, str):
        raise ValueError("Both arguments must be strings.")
    return ''.join(sorted(arg1 + arg2))