[Python] sorting list of decimals in python

Discussão em 'Python' iniciado por Stack, Fevereiro 16, 2025.

  1. Stack

    Stack Membro Participativo

    I have the following list that I'd like to sort:

    ['104.900209904', '238.501860857', '9.59893298149', '362.470027924', '419.737339973']

    I used the "sorted" function to do it:

    Block1_Video1 = sorted(Block1_Video1)


    However, this is what I get:

    ['104.900209904', '238.501860857', '362.470027924', '419.737339973', '9.59893298149']


    Whereas this is what I want (a list sorted numerically, taking decimal points into account):

    [''9.59893298149', 104.900209904', '238.501860857', '362.470027924', '419.737339973']


    How can I accomplish this?

    Continue reading...

Compartilhe esta Página