def insert(arr, x, order="descending"):
    """
    Inserts element in the correct position in sorted array
    (in the descending/ascending order of absolute values)
    """
    arr.append(x)
    i = len(arr) - 1

    if order == "descending":
        while (i != 0 and abs(arr[i]) > abs(arr[i - 1])):
            arr[i], arr[i - 1] = arr[i - 1], arr[i]
            i -= 1
    else:
        while (i != 0 and abs(arr[i]) < abs(arr[i - 1])):
            arr[i], arr[i - 1] = arr[i - 1], arr[i]
            i -= 1
    return arr