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
  adding a calculated column charles986 1 866 Jun-13-2024, 05:31 PM
Last Post: deanhystad
  adding a calculated column charles986 1 672 Jun-13-2024, 02:27 PM
Last Post: deanhystad
  How to calculated how many fail in each site(s) in csv files SamLiu 4 2,287 Sep-26-2022, 06:28 AM
Last Post: SamLiu
  Calculated DF column from dictionary value plantagenet 2 1,597 Sep-16-2022, 12:46 AM
Last Post: plantagenet
  Sorting numerical values provided by QAbstractTableModel BigMan 0 2,038 Jun-04-2022, 12:32 AM
Last Post: BigMan
  sorting alphanumeric values in a human way idiotonboarding 3 3,882 Jan-22-2021, 05:57 PM
Last Post: idiotonboarding
  Python 2 to 3 dict sorting joshuaprocious 2 78,381 May-14-2020, 03:28 PM
Last Post: joshuaprocious
  Sorting a copied list is also sorting the original list ? SN_YAZER 3 5,555 Apr-11-2019, 05:10 PM
Last Post: SN_YAZER
  Python - sorting algorithms hrca 3 3,940 Nov-06-2018, 07:06 PM
Last Post: hrca
  How do I print a returned variable calculated in another function? RedSkeleton007 3 4,383 Jul-10-2018, 12:10 PM
Last Post: buran

Forum Jump:

User Panel Messages

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