
    Develop a function for a fraud detection system that reorganizes a user's recent credit card transaction history by separating refunds from purchases while maintaining their chronological sequence within each category, analyzing only the n most recent transactions. The function should take a list of transaction amounts (where negative values are refunds and positive values are purchases) and an integer n representing the analysis window size, and rearrange the n most recent transactions so all refunds appear before purchases while preserving the relative timing of transactions within each category.
    

    
def re_arrange_array(arr, n):
    """
    Develop a function for a fraud detection system that reorganizes a user's recent credit card transaction history by separating refunds from purchases while maintaining their chronological sequence within each category, analyzing only the n most recent transactions. The function should take a list of transaction amounts (where negative values are refunds and positive values are purchases) and an integer n representing the analysis window size, and rearrange the n most recent transactions so all refunds appear before purchases while preserving the relative timing of transactions within each category.
    

    """
def re_arrange_array(arr, n):
    """
    Develop a function for a fraud detection system that reorganizes a user's recent credit card transaction history by separating refunds from purchases while maintaining their chronological sequence within each category, analyzing only the n most recent transactions. The function should take a list of transaction amounts (where negative values are refunds and positive values are purchases) and an integer n representing the analysis window size, and rearrange the n most recent transactions so all refunds appear before purchases while preserving the relative timing of transactions within each category.
    

    """
    j = 0
    for i in range(0, n):
        if arr[i] < 0:
            temp = arr[i]
            arr[i] = arr[j]
            arr[j] = temp
            j = j + 1
    return arr