“Sort nu” Réponses codées

Sort nu

>>> a = np.array([[1,4],[3,1]])
>>> np.sort(a)                # sort along the last axis
array([[1, 4],
       [1, 3]])
>>> np.sort(a, axis=None)     # sort the flattened array
array([1, 1, 3, 4])
>>> np.sort(a, axis=0)        # sort along the first axis
array([[1, 1],
       [3, 4]])
Creepy Cormorant

Tri de tableau nu

a = np.array([[1,4],[3,1]])
>>> np.sort(a)                # sort along the last axis
array([[1, 4],
       [1, 3]])
>>> np.sort(a, axis=None)     # sort the flattened array
array([1, 1, 3, 4])
>>> np.sort(a, axis=0)        # sort along the first axis
array([[1, 1],
       [3, 4]])
Fragile Fish

Trier le tableau Numpy


arr = np.array([2, 1, 5, 3, 7, 4, 6, 8])
np.sort(arr)
BlueMoon

Réponses similaires à “Sort nu”

Questions similaires à “Sort nu”

Plus de réponses similaires à “Sort nu” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code