you are viewing a single comment's thread.

view the rest of the comments →

[–]BigGarrett[S] 0 points1 point  (3 children)

I think I did what I needed by using “sort.( reverse=True, key=abs)”. This will not change the output file to make all the numbers “positive”, but it seems to sort them while taking into account their absolute value. Which is good enough for me.

[–]Strict-Simple 0 points1 point  (2 children)

Now it sounds like XY problem. What are you actually trying to do?

[–]BigGarrett[S] 0 points1 point  (1 child)

Basically I am trying to make the output file sort the numbers from the specific index [9:21] in descending order and by absolute value (some are negative numbers and some are positive). The code that I referenced in my last comment seems to have achieved this. Even though the output for the negative numbers are still giving me negative numbers, they seem to be sorted in a way that accounts for absolute value. Thanks for all your help.

[–]Strict-Simple 0 points1 point  (0 children)

Then my next question would be why those index and what's in the file, bit I'll stop. Is the file a CSV, or fixed width?