Python Forum
Sorting values calculated in python
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sorting values calculated in python
#1
Hi everyone,

So I have a script that is essentially an equation.

Each variable in the equation is a random number generated within predefined limits.

What the script ultimately does, is run 1000 times, and outputs 1000 different values.

From here, I copy the values in to excel and sort them there - I'd now like to do this within python.

What I wish to do is sort these 1000 values from largest to smallest, and then query and print values at certain stages within the sorted list.

I want to print the 100th value, 500th value and 900th value.

Any suggestions on how to achieve this will be greatly welcomed!

Happy coding!

Stuart
Reply
#2
What have you tried so far?
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#3
Asking my script nicely (i.e I don't even know where to start).

I'm a complete noob really.

I literally started with code academy a few days ago, got sidetracked with this project, and actually managed to get my script to work pretty painlessly.
Reply
#4
Bump.
Reply
#5
Instead of printing out the values, or writing them to a file or whatever, store them in a list.  Then you can sort the lsit the_list.sort().  Then boom, you're done :)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to calculated how many fail in each site(s) in csv files SamLiu 4 1,250 Sep-26-2022, 06:28 AM
Last Post: SamLiu
  Calculated DF column from dictionary value plantagenet 2 837 Sep-16-2022, 12:46 AM
Last Post: plantagenet
  Sorting numerical values provided by QAbstractTableModel BigMan 0 1,334 Jun-04-2022, 12:32 AM
Last Post: BigMan
  sorting alphanumeric values in a human way idiotonboarding 3 2,555 Jan-22-2021, 05:57 PM
Last Post: idiotonboarding
  Python 2 to 3 dict sorting joshuaprocious 2 53,701 May-14-2020, 03:28 PM
Last Post: joshuaprocious
  Sorting a copied list is also sorting the original list ? SN_YAZER 3 2,997 Apr-11-2019, 05:10 PM
Last Post: SN_YAZER
  Python - sorting algorithms hrca 3 3,112 Nov-06-2018, 07:06 PM
Last Post: hrca
  How do I print a returned variable calculated in another function? RedSkeleton007 3 3,493 Jul-10-2018, 12:10 PM
Last Post: buran
  Conditional sorting in Python amirt 1 6,369 Jul-05-2018, 01:32 PM
Last Post: buran
  sorting nested dict according to values merlem 6 17,468 Apr-01-2017, 10:01 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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