1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Sort all matrix

Discussão em 'Python' iniciado por Stack, Outubro 1, 2024 às 00:02.

  1. Stack

    Stack Membro Participativo

    I'm trying to sort a matrix if I have

    [[5 7 1 2]
    [4 8 1 4]
    [4 0 1 9]
    [2 7 5 0]]


    I want this result

    [[9 8 7 7]
    [5 5 4 4]
    [4 2 2 1]
    [1 1 0 0]]


    this is my code, I'm using random numbers

    import numpy as np

    MatriX = np.random.randint(10, size=(4,4))
    print(MatriX)
    for i in range(10):
    for j in range(10):
    a=np.sort(-MatriX,axis=1)*-1
    b=np.sort(-a,axis=0)*-1
    c=np.transpose(b)

    d=np.sort(-c,axis=1)*-1
    e=np.sort(-d,axis=0)*-1


    print(e)


    but this code, don't work at all

    Continue reading...

Compartilhe esta Página