0

[Challenge] Decimal Sorter

A script which first sorts decimal numbers by highest - lowest and then lowest - highest Decimals: 0,2885 0,00653 0,006406 0,916 0,3306

20th May 2018, 6:19 PM
Hampus Mathiesen
Hampus Mathiesen - avatar
2 Respuestas
+ 1
numbers = [ 0.2885, 0.00653, 0.006406, 0.916, 0.3306] print(sorted(numbers)) print("\n", sorted(numbers)[::-1]) you get the general idea :) . p.s. this doesn't sort the decimals it only gives a sorted output
20th May 2018, 8:23 PM
Markus Kaleton
Markus Kaleton - avatar
+ 1
using sort method it is possible to sort a list in place also in reverse order.
22nd May 2018, 5:21 PM
tamaslud
tamaslud - avatar