def merge_sort(nsl: list) -> list:
    """
    function sorts an array by a merge method.
    :param nsl: type list: non sorted list
    :return: type list: list after merge sort
    """

    sl = nsl[:]
    n = len(nsl)
    if n < 2:
        return sl
    else:
        left_arr = merge_sort(nsl=nsl[:n//2])
        right_arr = merge_sort(nsl=nsl[n//2:n])

        sl = []
        i = 0
        j = 0

        while i < len(left_arr) or j < len(right_arr):
            if not (i < len(left_arr)):
                sl.append(right_arr[j])
                j += 1

            elif not (j < len(right_arr)):
                sl.append(left_arr[i])
                i += 1

            elif not (left_arr[i] > right_arr[j]):
                sl.append(left_arr[i])
                i += 1

            else:
                sl.append(right_arr[j])
                j += 1

        return sl