Python Forum
Question about Sorting a List with Negative and Positive Numbers
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question about Sorting a List with Negative and Positive Numbers
#2
just use:
>>> numbers = [11.5, 28.3, 23.5, -4.8, 15.9, -63.1, 79.4, 80.0, 0, 67.4, -11.9, 32.6]
>>> numbers.sort()
>>> numbers
[-63.1, -11.9, -4.8, 0, 11.5, 15.9, 23.5, 28.3, 32.6, 67.4, 79.4, 80.0]
>>>
Reply


Messages In This Thread
RE: Question about Sorting a List with Negative and Positive Numbers - by Larz60+ - Nov-14-2019, 12:36 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Random Generator: From Word to Numbers, from Numbers to n possibles Words Yamiyozx 2 1,492 Jan-02-2023, 05:08 PM
Last Post: deanhystad
  sorting a list using unicodes acending order, no loops, no sort(), using recursion lrn2codee 14 6,566 Jun-23-2021, 07:33 PM
Last Post: deanhystad
  Sorting list - Homework assigment ranbarr 1 2,276 May-16-2021, 04:45 PM
Last Post: Yoriz
  Input validation for nested dict and sorting list of tuples ranbarr 3 3,961 May-14-2021, 07:14 AM
Last Post: perfringo
  Convert list of numbers to string of numbers kam_uk 5 3,092 Nov-21-2020, 03:10 PM
Last Post: deanhystad
  Positive and negative numbers in a row peterp 1 1,781 Oct-29-2020, 02:42 AM
Last Post: deanhystad
  insert() but with negative index naughtysensei 1 2,411 Oct-01-2020, 03:05 AM
Last Post: micseydel
  Return the sum of the first n numbers in the list. pav1983 3 4,200 Jun-24-2020, 03:37 AM
Last Post: deanhystad
  numbers in list - max value and average stewie 2 2,869 Apr-01-2020, 06:25 PM
Last Post: buran
  negative indices in lists Ironword 6 3,552 Jan-08-2020, 01:00 PM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020