Hackerss.com

hackerss
hackerss

Posted on

Sort an array of integers in Python

Sort an array of integers - Python:


def sort_array(arr):
    """
    Sort an array of integers.

    Parameters
    ----------
    arr : list
        The array to sort.

    Returns
    -------
    list
        The sorted array.
    """

    #sort the array and return it
    return sorted(arr)

#example
result = sort_array([1, 2, 3, 4, 5])
#output
print(result)  #[1, 2, 3, 4, 5]


Enter fullscreen mode Exit fullscreen mode

Top comments (0)